| Start |
|---|
| Creating a simple JSON object Create the The resulting |
| Create a JSON String with null value. If you need to produce a JSON string with a value of Then you have to use the special constant JSONObject.NULL (opens new window). Functioning example: |
Add JSONArray to JSONObject The resulting JSON string looks like this: |
| Parse simple JSON object Consider the following JSON string: This JSON object can be parsed using the following code: Here is another example with a JSONArray nested inside JSONObject: This can be parsed with the following code: |
| Create nested JSON object To produce nested JSON object, you need to simply add one JSON object to another: Now |
| Check for the existence of fields on JSON Sometimes it's useful to check if a field is present or absent on your JSON to avoid some To achieve that, use the Sample JSON Java code |
Working with null-string when parsing json If we will use this way: We will have output: So we need to provide this workaround: And then call: And we will have Output as we expected: |
| Using JsonReader to read JSON from a stream
|
| Handling dynamic key for JSON response This is an example for how to handle dynamic key for response. Here Response Java code |
| Updating the elements in the JSON sample json to update To update the elements value in the json we need to assign the value and update. updated value SyntaxRemarksThis topic is about using the |
Read Article
https://develop.horje.com/learn/1434/reference