2

I am new to J2EE and JSON. I am using jsonArray.put(jsonObject) for adding a json object to a json array but its showing error message:

The method put(JSONObject) is undefined for the type JSONArray.

The library I am using for json is org.json.simple.*

Please help me out.

1 Answer 1

4

The method to put new stuff into an array is called add. So:

jsonArray.add(jsonObject)

should work.

Please refer to the documentation for details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.