Android JSON in Android with org.json Create a JSON String with null value.

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

If you need to produce a JSON string with a value of null like this:

{  
   "name":null
}

Then you have to use the special constant JSONObject.NULL.

Functioning example:

jsonObject.put("name", JSONObject.NULL);


Got any Android Question?