I'm receiving an JSON String in my Server which has only two parameters: name and number. Find example below:
{"name":"outlet.jpg","numbar":"2"},{"name":"image.jpg","number":"3"}, {"name":"testing.jpg","number":"1"}
I'm trying to unpack this values in a String Array. How can I do it?
This is what I have so far:
JSONObject jsonObject;
try {
jsonObject = new JSONObject(jsonString.substring(1, jsonString.length()-1));
String name = jsonObject.getString("name");
String number = jsonObject.getString("number");
System.out.println("nome: " + name + " number: " + number);
} catch (JSONException e) {
e.printStackTrace();
}
There's no getString() in jsonObject which returns an Array. This example is only getting the first element of the JSON String.. How can I receive an String Array for each key of JSON String?