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()
int size = exampleList. size(); String[] stringArray = exampleList. toArray(new String[size]); This will convert our JSON array into a String array.
We can also add a JSONArray to JSONObject. We need to add a few items to an ArrayList first and pass this list to the put() method of JSONArray class and finally add this array to JSONObject using the put() method.
JSONObject json = RestManager. getJSONfromURL(myuri); // retrieve the entire json stream JSONArray interventionJsonArray = json. getJSONArray("intervention"); In the first case, the above doesn't work because there is only one element in the stream..
You can remove an element from the JSONArray object using the remove() method. This method accepts an integer and removes the element in that particular index.
As long as it's a valid JSONArray to begin with, then yes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With