Hello,
I'm using the library to make ReST calls and parse the JSON response into a Java object. The JSON string may contain null values.
Previously, I was using Spring Android to handle HTTP requests and GSON to parse the responses.
Using GSON only, a null JSON value would correspond to a Java null object. Currently, however, a null JSON value corresponds to a Java Object:
JSON: {"something":null}
toString(): something=java.lang.Object@41f456301
private String something;
public String getSomething()
{
if(something == null) return null;
if(Data.isNull(something))
Log.d(TAG, "Data.isNull(something)");
else
Log.d(TAG, "NOT Data.isNull(something)");
return (Data.isNull(something) ? null : something);
}
The code above prints:
NOT Data.isNull(something)
something=java.lang.Object@41f456301
I would expect the variable 'something' to be equal to 'Data.NULL_STRING' but it isn't. Now, I could use the object representing a null Java value to compare against the variable when necessary, but I can't figure out which one it is.
Other JSON names which values are null also point to the exact same object (based on the address printed).
Long story short, how do I know if a value is actually null?