You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe XML class needs to consider that, on cases where a Json code like below is sent:
{
"test":
{ "child": null }
}
is currently being converted as:
<test>
<child>null</child>
</test>
rather than:
<test>
<child/>
</test>
And this is due to an if structure made on the line 408 (XML.java). This comparison needs to be overriding by equals() method. Otherwise, it compares by references:
XML.toString(Object object, String tagName) {
...
/*value is type JSONObject*/
value = jo.opt(key);
/*408*/ if (value == null) {
value = "";
}
I suggest something like value.equals(null) and the problem would be fixed.
Regards
The text was updated successfully, but these errors were encountered:
Inclined to agree that this may be a bug. The toString() output would be correct in a JSON doc, but maybe not so much in an XML doc. However, there are a couple of problems:
Why is the proposed solution the best choice, given that XML does not support null (as far as I know)?
I think the analysis may be incomplete. For example, the Javadoc for JSONObject.opt(key) says that it may return null. Perhaps that is the purpose of line 408.
Can't proceed with this issue as it is currently stated, but feel free to resubmit after addressing the above items.
Hi,
I believe XML class needs to consider that, on cases where a Json code like below is sent:
{
"test":
{ "child": null }
}
is currently being converted as:
rather than:
And this is due to an if structure made on the line 408 (XML.java). This comparison needs to be overriding by equals() method. Otherwise, it compares by references:
I suggest something like value.equals(null) and the problem would be fixed.
Regards
The text was updated successfully, but these errors were encountered: