staxon icon indicating copy to clipboard operation
staxon copied to clipboard

handaling of empty string in json to xml to json conversion

Open rajeevaec opened this issue 9 years ago • 1 comments

I am using staxon to convert json to xml and then same xml to json i.e. json <-->xml<-->json

while doing so when I am giving following json

{ "emptyKey" : "", "nullKey" :null }

which is getting converted into this xml with virtual root

"<root-Element><emptyKey></emptyKey><nullKey></nullKey></root-Element>"

now when I convert this xml back to JSON I am getting json

{ "emptyKey" : null, "nullKey" : null }

basically empty string is converted into null, Is there any way to handle empty string properly.

rajeevaec avatar Aug 09 '16 10:08 rajeevaec

There is currently no way to handle this, i.e. there is no null in XML. There is a pull request to support the xsi:nil attribute, see https://github.com/beckchr/staxon/pull/27. However, this needs some more investigation.

beckchr avatar Aug 19 '16 17:08 beckchr