Reputation: 1312
I want to parse json, but I didn't find how to parse array from this structure:
{
"0": {
"title": "\u0417\u041d: \u0415\u0432\u0440\u043e\u043f\u0435\u0439\u0446\u044b ",
"date": "2011-11-26 14:33:00"
},
"1": {
"title": "\u041a\u0430\u043a\u0430\u044f ",
"date": "2011-11-25 13:55:00"
},
"2": {
"title": "\u0423\u043a\u0440\u0430\u0438\u043d\u0430",
"date": "2011-11-25 11:15:00"
},
"3": {
"title": "\u0423\u0416\u0421\u041a ",
"date": "2011-11-24 15:45:00"
},
"time": 0.03944993019104
}
Upvotes: 0
Views: 448
Reputation: 17942
Try parsing these as JSONObject and then accessing it's values keys provided.
To be more specific:
try {
JSONObject foo = new JSONObject(youJsonString);
foo.get(name)
} catch (JSONException e) {
//handle exceptions
}
Upvotes: 1
Reputation: 22633
See, the problem is you don't actually have an array. You have a series of dictionaries, keyed by index. The only way to do this is to iterate over each numerical key, and add its value to a list.
Here's some pseudocode to help you get started:
yourArray = new Array(yourJSON.keys.length)
for key in yourJSON.keys:
yourArray.put(yourJSON[key], int(key))
You'll need to make a new array object whose length is equal to the number of keys. Then, put each of the values for each key at index key
.
Upvotes: 1