JSON to XML to JSON conversion not the same
Opened this issue · 0 comments
federico-piazza commented
Hi guys,
I've have the following JSON:
{
"RESULTS": [
{
"@elem": 0,
"ACCOUNT_OBJ": "",
"END_T": 0,
"POID": ""
}
]
}
When I transform it to XML the result is:
<?xml version="1.0" encoding="UTF-8"?><flist>
<RESULTS elem="0">
<ACCOUNT_OBJ/>
<END_T>0</END_T>
<POID/>
</RESULTS>
</flist>
And when I transform it back to JSON using:
JsonXMLConfig config = new JsonXMLConfigBuilder()
.autoPrimitive(true)
.build()
The resulting JSON is:
{
"RESULTS": [
{
"@elem": "0",
"ACCOUNT_OBJ": null,
"END_T": 0,
"POID": null
}
]
}
Not sure if I'm doing something wrong or misunderstood the autoPrimitive
flag but I get the string "0" for @elem
instead of the primitive 0
. Is this a bug?
On the other hand, I know the convention is that <POID/>
is converted to "POID":null
. Is it possible to transform it back to empty string?
Also, another problem is that whitespaces string like " "
are converted to null.