XML -> JSON: Empty XML elements are converted to quoted string "NULL" instead of to null

Not applicable

Hi,

I'm using an auto-generated JSON -> SOAP -> JSON policy to support an old SOAP service and I'm having a problem where empty nodes in the SOAP XML are getting converted to an uppercase quoted string containing the word "NULL" instead being converted to the actual null value for an object.

The empty node might look like this:

<regionCode></regionCode>

Rather than having the JSON be null ("regionCode": null, ...) it's coming in as the literal uppercase string "NULL" like this: "regionCode": "NULL".

Solved Solved
1 2 3,230
1 ACCEPTED SOLUTION

Not applicable

ANSWER: Another geek hipped me to this. In my XML-to-JSON Policy there are a couple of configuration elements that need to be set in specific ways to make this work properly, for some reason the default generated settings aren't correct.

You need to have this:

<RecognizeNull>true</RecognizeNull>

In my case I also had this:

<NullValue>NULL</NullValue>

This NullValue element should not be here. What this appears to do is take the text within this element, i.e. the literal string "NULL", quotes it and puts it where ever the null value is. What made this work for me was simply to remove (or comment out) this element entirely.

View solution in original post

2 REPLIES 2

Not applicable

ANSWER: Another geek hipped me to this. In my XML-to-JSON Policy there are a couple of configuration elements that need to be set in specific ways to make this work properly, for some reason the default generated settings aren't correct.

You need to have this:

<RecognizeNull>true</RecognizeNull>

In my case I also had this:

<NullValue>NULL</NullValue>

This NullValue element should not be here. What this appears to do is take the text within this element, i.e. the literal string "NULL", quotes it and puts it where ever the null value is. What made this work for me was simply to remove (or comment out) this element entirely.

auto-correct fail: that was supposed to be "...another GEEK"