2

I have a String which contains many JSONObjects. I need to convert that String to JSONArray. Please help.

""{\""Name\"":\""name1\"",\""Age\"":\""20\"",\""S.No.\"":\""1\""},
 {\""Name\"":\""name2\"",\""Age\"":\""21\"",\""S.No.\"":\""2\""},
 {\""Name\"":\""name3\"",\""Age\"":\""22\"",\""S.No.\"":\""3\""}""
0

2 Answers 2

4

Wrap the string in "[]" and then use the JSON parser of your choice.

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

1 Comment

Thank you.. after adding "[ ]" to the String, JSONArray arr = new JSONArray(string); converts the string to JSONArray.
0

There is Java Lib called Quick-json - A java library to convert json string to java objects & java objects to json string. parse/generate json the way you want quickly. configure/validate json at every level.

Please refer for Quick- Json Lib https://code.google.com/p/quick-json/ has good example's as well as explanation.

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.