Converting from JSONArray to String then back again

JavaAndroidStringJson

Java Problem Overview


I need to store a JSONArray object as a string then retrieve the string and convert it back to a JSONArray.

If I do:

JSONArray jArray;
String s = jArray.toString()
JSONArray newJArray = new JSONArray(s);

Will I get back the same object?

I'm trying to store a JSONArray in a SQLite database.

Here's what I'm looking at. http://developer.android.com/reference/org/json/JSONArray.html#toString()

Java Solutions


Solution 1 - Java

As long as it's a valid JSONArray to begin with, then yes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNick RempelView Question on Stackoverflow
Solution 1 - JavaJason RobinsonView Answer on Stackoverflow