Reputation: 888
How do i strip out fields of a JSON object returned in a Logic App HTTP response if the value is null?
Current response message sample:
{
"Name": "John",
"Age": 20,
"Address": null
}
But requires:
{
"Name": "John",
"Age": 20,
}
Thanks
Upvotes: 1
Views: 848
Reputation: 169
Alternatively you could use the logic below in case you expect other fields to be empty besides the Address
{
{% if content.Name != nil %}
"Name": "{{ content.Name }}",
{% endif %}
{% if content.Age != nil %}
"Age": "{{ content.Age }}",
{% endif %}
{% if content.Address != nil% }
"Address": "{{ content.Address }}"
{% endif %}
}
Upvotes: 1
Reputation: 1474
You can do it with an Integration Account and a Liquid Map as this:
{
{% if content.Address == empty %}
"Name": "{{ content.Name }}",
"Age": "{{ content.Age }}"
{% else %}
"Name": "{{ content.Name }}",
"Age": "{{ content.Age }}",
"Address": "{{ content.Address }}"
{% endif %}
}
Using a Transform JSON to JSON shape:
Upvotes: 3