Skip to content
Advertisement

How to put/get multiple JSONObjects to JSONArray?

Is it possible to store multiple different JSONObjects into a single JSONArray? This is the structure, I want to store in a JSONArray.

JavaScript

Here’s the code where I am setting JSONObject and putting it into a JSONArray

JavaScript

Using this code only the last value, which I am setting in JSON object Override to all objects. Any suggestions to achieve this?

Advertisement

Answer

I found very good link for JSON: http://code.google.com/p/json-simple/wiki/EncodingExamples#Example_1-1_-_Encode_a_JSON_object

Here’s code to add multiple JSONObjects to JSONArray.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement