如果值是null,如何去除Logic App HTTP响应中返回的JSON对象的字段?
当前响应消息示例:
{
"Name": "John",
"Age": 20,
"Address": null
}
但要求:
{
"Name": "John",
"Age": 20,
}
谢谢
答案 0 :(得分:3)
您可以使用集成帐户和液体地图来做到这一点:
{
{% if content.Address == empty %}
"Name": "{{ content.Name }}",
"Age": "{{ content.Age }}"
{% else %}
"Name": "{{ content.Name }}",
"Age": "{{ content.Age }}",
"Address": "{{ content.Address }}"
{% endif %}
}
使用将JSON转换为JSON 形状:
答案 1 :(得分:1)
或者,如果您希望除“地址”之外的其他字段为空,则可以使用以下逻辑
{
{% if content.Name != nil %}
"Name": "{{ content.Name }}",
{% endif %}
{% if content.Age != nil %}
"Age": "{{ content.Age }}",
{% endif %}
{% if content.Address != nil% }
"Address": "{{ content.Address }}"
{% endif %}
}