0
I’m trying but not sure, I wanted to put it in the hand created, as if I had already received my JSON file. I tried to put the JSON structure inside Jsonobject but it didn’t work.
0
I’m trying but not sure, I wanted to put it in the hand created, as if I had already received my JSON file. I tried to put the JSON structure inside Jsonobject but it didn’t work.
0
If you pass your String in JSON format to your Jsonobject object, you can do something like this:
try {
String stringJSON = "{interests : [{interestKey:Dogs}, {interestKey:Cats}]}";
JSONObject obj = new JSONObject(stringJSON);
List<String> list = new ArrayList<String>();
JSONArray array = obj.getJSONArray("interests");
for (int i = 0; i < array.length(); i++) {
list.add(array.getJSONObject(i).getString("interestKey"));
}
} catch (JSONException e) {
e.printStackTrace();
}
Source: Parsing JSON Object in Java
Browser other questions tagged android json
You are not signed in. Login or sign up in order to post.