How can we define null as a datatype in Android, like we define nsNull in iPhone How can we define null as a datatype in Android, like we define nsNull in iPhone json json

How can we define null as a datatype in Android, like we define nsNull in iPhone


Try using JSONObject.NULL instead of null, if you are using org.json.

Referenced from documentation.

edit

I tried, creating an json object with null as value, something like this.

    JSONObject jsonObject = new JSONObject();    jsonObject.put("Test", JSONObject.NULL);

and the output generated on printing it was, {"Test": null}

So, I guess this will do the magic for you. :)