Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

jsonObject.accumulate("status",null);

I want to pass null as a value in json service call i try ""," ", NULL, nil,"null" but nothing helps

Could anyone have solution for this ?

like image 423
Shailendrasinh Gohil Avatar asked Jun 07 '16 13:06

Shailendrasinh Gohil


1 Answers

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. :)

like image 106
Dave Ranjan Avatar answered Oct 09 '22 23:10

Dave Ranjan