Extract Variables drop fields with null value

Good, morning.

I have use Extract Variables to format my message return to my clients.

But I noted today that when a field has a null value, this policy is drop this field from my new variable.

My policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="EV-RemoveCurly">
<DisplayName>EV-RemoveCurly</DisplayName>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="newData" type="nodeset">
<JSONPath>$.data</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">response</Source>
</ExtractVariables>

 

My response
{
"code":200,
"message":"ok",
"data":{
"general_info":{
"response_type":"STATUS",
"operation_tracking_id":"id",
"external_id":null
}
}

 

Policy drop field
{
"code":200,
"message":"ok",
"data":{
"general_info":{
"response_type":"STATUS",
"operation_tracking_id":"id",
}
}

Can someone help me?

Thanks!

Solved Solved
0 2 1,305
1 ACCEPTED SOLUTION

AFAIK, in general there is no clear definition for how to handle null versus not-present values in JSON structures. And I guess the ExtractVariables policy treats null as not present. 

If you must be able to handle a null value as differentiated from not-present, then a better way to do what you want may be to use a JavaScript policy.

 

View solution in original post

2 REPLIES 2

AFAIK, in general there is no clear definition for how to handle null versus not-present values in JSON structures. And I guess the ExtractVariables policy treats null as not present. 

If you must be able to handle a null value as differentiated from not-present, then a better way to do what you want may be to use a JavaScript policy.

 

Thanks for your advice, @dchiesa1 !

I will try to use JavaScript.