Possible Duplicate:
Sending and Parsing JSON in Android
EDIT: Finally I found an answer to get array value without key value by using Iterator. I just got an idea from this link
I am just newbie to JSON Parsing, and I have no idea how to parse this kinda JSONArray. Can anyone give me a hint ?
{
"pages": [
"image1.jpg",
"image2.jpg"
]
}
You have to understand the basic concepts of JSON .
{}talks about an instance (called JSONObject)[]talks about an array of somethings (called JSONArray in Android)"xxx":"yyy"talks about key & valueFirst, you may let the reply json string become an JSONObject,
JSONObject replyJSON = new JSONObject(reply)Then, get the JSONArray named ‘pages’ inside the replied JSONObject,
JSONArray pagesArray = replyJSON.getJSONArray("pages")Finally, get the value inside the JSONArray by the method
getString, in your example, you may use pagesArray.getString(0) and pagesArray.getString(1)Check out the documentation for more details:
JSONArray