My JSON response is as follows:
["Sting - We Work The Black Seam",
"Bob Marley - No woman no cry",
"Bob Marley - Redemption song",
"Peter Gabriel - Solsbury Hill",
"Elton John - Candle in the wind",
"Elton John - I'm still standing",
"Bernard Lavilliers - Noir et blanc",
"Michel Polnareff - Love me"]
first let me know if its a proper JSON.
If its so then how to read this info..??
since it doesn’t have any name for array or even for single element.
Thank you all..
Now got it how to do..
public ArrayList<String> createPlaylist(String result) {
try {
json = new JSONArray(result);
System.out.println("Json Values : " + json);
} catch (JSONException e) {
e.printStackTrace();
}
ArrayList<String> list = new ArrayList<String>();
if (json != null) {
int len = json.length();
for (int i = 0; i < len; i++) {
try {
list.add(json.get(i).toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
return list;
}
Is this correct..
plz let me know..
Regards,
Mounika
It is valid JSON. You can check this online at
http://jsonformatter.curiousconcept.com/
To read it in JavaScript, you access it like an array. If you are getting it as a string then you need to parse it into a valid JavaScript construct using something the JSON library found at:
https://github.com/douglascrockford/JSON-js
E.g.