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 was curious why an element in the JSONArray is real null, instead of the Null object defined in JSONObject, and the reason is that method of JSONArray
public JSONArray put(Object value) {
this.myArrayList.add(value);
return this;
}
Maybe the correct code is:
public JSONArray put(Object value) {
this.myArrayList.add(JSONObject.wrap(value));
return this;
}
A NPE can occur if we try to serialize a JSONArray that contains a 'null' value. The NPE occurs in JSONObject @ line 1509, which is:
At this point 'value' can be null.
This can be fixed very easy. We just need to move the if statement @ line 1523 to be the first:
The text was updated successfully, but these errors were encountered: