---
title: "fswa_normalize_object — Filter Hook"
description: "Converts custom PHP objects in hook arguments into plain arrays for JSON serialization."
url: "https://wpwebhooks.org/docs/fswa-normalize-object/"
---

[WP Webhooks](https://wpwebhooks.org/) / [Docs](https://wpwebhooks.org/docs/) / fswa\_normalize\_object

Filter since v1.5.0

# fswa\_normalize\_object

Converts custom PHP objects in hook arguments into plain arrays for JSON serialization.

/ Signature

```
apply_filters( 'fswa_normalize_object', $data, $object )
```

/ When it fires

Fires for each PHP object encountered when serializing WordPress hook arguments to JSON — except closures, `DateTimeInterface` and `Traversable` objects, which are converted before this filter runs.

/ Parameters

| Name | In | Type | Req | Description |
| --- | --- | --- | --- | --- |
| $data | param | mixed | yes | Current normalized value — \`null\` initially. Return an array to replace the object. |
| $object | param | object | yes | The PHP object to normalize (e.g. a \`WPCF7\_Submission\`). Use \`instanceof\` or \`get\_class()\` to pick yours. |

/ Returns

`array|null` Return an array to use as the object's representation; its values are normalized recursively and a \`\_\_type\` key with the class name is added. Return anything else (leave \`null\`) to fall through to the default extraction: \`get\_data()\`, then \`jsonSerialize()\`, then \`get\_properties()\`, then the public properties.

/ Examples

Normalize a custom form submission object

```
add_filter( 'fswa_normalize_object', function ( $data, $object ) {
    if ( ! $object instanceof My_Form_Submission ) return $data;
    return [
        'form_id' => $object->get_form_id(),
        'fields'  => $object->get_fields(),
    ];
}, 10, 2 );
```

/ Related

[Contact Form 7 Integration](https://wpwebhooks.org/docs/cf7-integration/)[IvyForms Integration](https://wpwebhooks.org/docs/ivyforms-integration/)[fswa\_payload](https://wpwebhooks.org/docs/fswa-payload/)

/Ready

## Your next automation is  
one sentence away.

[Try the Live Preview](https://playground.wordpress.net/?blueprint-url=https://wpwebhooks.org/blueprint.json) [See the Plugin →](https://wpwebhooks.org/wordpress-webhook-plugin/)

$ wp plugin install flowsystems-webhook-actions --activate

## Structured data

```json
{"@context":"https://schema.org","@type":"TechArticle","name":"fswa_normalize_object — Filter Hook — Webhook Actions Docs","description":"Converts custom PHP objects in hook arguments into plain arrays for JSON serialization.","url":"https://wpwebhooks.org/docs/fswa-normalize-object/","isPartOf":{"@type":"WebSite","name":"WP Webhooks","url":"https://wpwebhooks.org"},"about":{"@type":"SoftwareApplication","name":"Webhook Actions","applicationCategory":"WordPress Plugin"}}
```
