Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented jsonMerge removeNulls=true behaviour #339

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions _docs/response-templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,43 @@ Like the `jsonArrayAdd` helper, the second object can be provided as a block:

{% endraw %}

### Removing attributes
The `jsonMerge` helper has an optional `removeNulls` parameter which, when set to true will remove any attributes from the resulting JSON that
have null values in the second JSON document.

So for instance, given the following template:

{% raw %}

```handlebars
{{#assign 'object1'}}
{
"keepMe": 1,
"removeMe": 2
}
{{/assign}}

{{#jsonMerge object1 removeNulls=true}}
{
"removeMe": null
}
{{/jsonMerge}}
```

{% endraw %}

The resulting JSON would be:

{% raw %}

```json
{
"keepMe": 1
}
```

{% endraw %}

## Removing from a JSON Array or Object

The `jsonRemove` helper was introduced in WireMock `3.10.0` and allows you to remove an element from an existing json
Expand Down