user can add items to cart and simultaneously an url will be fired and an json will be returned..user can add any number of products..each product has an unique product_id.now each product can have many suppliers..suppliers also have unique supplier_id..for all the items added into the cart supplier may be common for few..say we have 5products into cart and..supllier1(having unique id) supplies 3products and supplier2(having unique id) supplies 2products..now i have found out and added unique supplier_id's in a array list..in each json object there is a field called price..I have to add the prices for a unique supplier..so for 2suppliers 2 seperate prices will be shown..(1st for supplier1 by adding prices of 3products he supplies)and other for supplier2..
part of json is
{
"BasketItemID": "4455",
"BasketID": "11",
"ProductID": "12909",
"Qty": "1",
"SupplierID": "7",
"Code": "END10-001",
"Name": "ENDO STOPPERS (100)",
"Price": "5.72",
"GST": "0.64",
"PriceGST": "6.36",
"Brand": "DENT AMERICA",
"Thumbnail": null,
},
{
"BasketItemID": "4464",
"BasketID": "11",
"ProductID": "12914",
"Qty": "1",
"SupplierID": "7",
"Code": "INS52-361",
"Name": "AMALGAM GUN CVD 45' PLASTIC",
"Price": "17.00",
"GST": "1.70",
"PriceGST": "18.70",
"Brand": "LARIDENT",
"Thumbnail": null,
},
{
"BasketItemID": "4465",
"BasketID": "11",
"ProductID": "13863",
"Qty": "1",
"SupplierID": "5",
"Code": "9516068",
"Name": "Tofflemire Bands #3 0015 Pkt 12",
"Price": "2.24",
"GST": "0.22",
"PriceGST": "2.47",
"Brand": "Rand",
"Thumbnail": null,
},
so how can i add the prices?
If your problem revolves around parsing a JSON array you may want to check out the example here. Then you would filter by supplier, feel free to let me expand if you want to make your requirements more explicit.
It would look something like this (not tested)
Integer id;
Map<Integer, Double> sums;
...
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("SupplierID")) {
id = reader.nextInt();
} else if (name.equals("Price")) {
if(!sums.containsKey(id)){
sums.put(id, reader.nextDouble());
}
else{
Double f = (Double) sums.get(id);
sums.put(id, f+reader.nextDouble());
}
} else {
reader.skipValue();
}
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I recently started working with andorid.
How to parse dynamic json with multiple arrays response from php server.
Login Response
{
"status": 1,
"data": {
"msg": "LoggedIn",
"user_id": "2"
}
}
Login response with error message
{
"status": 0,
"data": "No users found with given email."
}
and an other one
Inventory List
{
"status": 1,
"data": [
{
"inventory_id": "33",
"apron_id": "123456",
"nickname": "uyi",
"location": "13",
"manufacture": "0",
"garment_type": "yuyh",
"color": "juki",
"core_material": "ytyt",
"Date_purchase": "2015-04-10",
"UID_no": "ikujki",
"serial": "iui",
"Batch": "ikk",
"Expiration": "2015-04-23",
"QTY": "898",
"apron_status": "0",
"apron_retire": "0",
"created_user": "2",
"created_time": "2015-04-10 05:22:38",
"update_time": "2015-04-10 05:22:38"
},
{
"inventory_id": "32",
"apron_id": "12345mn",
"nickname": "gfhgh",
"location": "12",
"manufacture": "0",
"garment_type": "hgjyhj",
"color": "ytgtfghtg",
"core_material": "fhgfhy",
"Date_purchase": "2015-04-28",
"UID_no": "rtryttttttttt",
"serial": "hfh",
"Batch": "rtrrtyy",
"Expiration": "2015-03-17",
"QTY": "7688",
"apron_status": "0",
"apron_retire": "0",
"created_user": "2",
"created_time": "2015-04-10 05:15:54",
"update_time": "2015-04-10 05:15:54"
}
]
}
Thanks in advance.
to get login response you can do like this
JSONObject jobj=new JSONObject(result.toString());
String status=jobj.getString("status");
if(status.equalsIgnoreCase("1"))
{
//login success
JSONObject Jdata=jobj.getJSONObject("data");
String Message=Jdata.getString("msg");
String UserId=Jdata.getString("user_id");
}
else
{
//failure
}
and for Inventory List you can do like this
JSONObject jobj=new JSONObject(result.toString());
JSONArray arrData=jobj.getJSONArray("data");
for (int i = 0; i < arrData.length(); i++)
{
JSONObject jdata=arrData.getJSONObject(i);
//here u can get all field like this
String nickname=jdata.getString("nickname");
}
Investigate the JSONObject and JSONArray classes.
You can parse extremely simply:
JSONObject json = new JSONObject(jsonString);
int status = json.getInt("status");
Using both an Array and an Object for your "data" key will make things irritating for you. You should think about using a different key, or another key that will dictate to you what you are reading.
My requirement is simple, i have a JSON file in webserver and i have to parse it in android and i know the parsing method, but i have to display the output by different way in the following JSON file,
{
"Productcategory": [
{
"shop_cat_id": "1",
"shop_cat_name": "kurtis",
"shop_scat_id1": "1",
"shop_scat_id1name": "cotton kurtis",
"shop_scat_id2": "2",
"shop_scat_id2name": "Cotton Designer Kurtis",
"shop_scat_id3": "3",
"shop_scat_id3name": "soft Designer kurtis"
},
{
"shop_cat_id": "2",
"shop_cat_name": "Sarees",
"shop_scat_id1": "1",
"shop_scat_id1name": "Saree 1",
"shop_scat_id2": "2",
"shop_scat_id2name": "Saree 2",
"shop_scat_id3": "3",
"shop_scat_id3name": "Saree 3",
"shop_scat_id4": "4",
"shop_scat_id3name": "Saree 4"
},
{
"shop_cat_id": "3",
"shop_cat_name": "Anarkkali suits",
"shop_scat_id1": "1",
"shop_scat_id1name": "Readymade",
"shop_scat_id2": "2",
"shop_scat_id2name": "Stitched",
"shop_scat_id3": "3",
"shop_scat_id3name": "Unstitched"
},
{
"shop_cat_id": "4",
"shop_cat_name": "CottonLeggins",
"shop_scat_id1": "1",
"shop_scat_id1name": "LSize",
"shop_scat_id2": "2",
"shop_scat_id2name": "XLsize",
"shop_scat_id3": "3",
"shop_scat_id3name": "3XLsize",
"shop_scat_id4": "4"
},
{
"shop_cat_id": "5",
"shop_cat_name": "PattialaPantsset",
"shop_scat_id1": "1",
"shop_scat_id1name": "LSize",
"shop_scat_id2": "2",
"shop_scat_id2name": "XLsize",
"shop_scat_id3": "3",
"shop_scat_id3name": "3XLsize",
"shop_scat_id4": "4"
},
{
"shop_cat_id": "6",
"shop_cat_name": "Kids'AnarkkaliSuits",
"shop_scat_id1": "1",
"shop_scat_id1name": "LSize",
"shop_scat_id2": "2",
"shop_scat_id2name": "XLsize",
"shop_scat_id3": "3",
"shop_scat_id3name": "3XLsize",
"shop_scat_id4": "4"
}
]
}
I fetched the "shop_cat_name" field in a separate ListView and it looks like below,
I need to display the subcategory in separate ListView for each Category Clicked.
But when i parse the "shop_scat_id1name" field, the data fetching in all the array fields with different category name like below image,
My required output should be like below when i click the first category and similarly for other category based on their subcategory..
Category name i click
Kurtis
Subcategory should be
Cotton kurtis
Cotton Designer Kurtis
Soft Designer Kurtis
By what way i have to modify the JSON structure or anything i need to do in coding part?
Help Needed..
I guess you get the vaule from JSON like this : String name=JSON.getString("shop_scat_id1name");
It's wrong.
Wait a minute,I'll give you some examples.
My English is very poor.Very sorry.
First
you should create a entity like this that will stored value.
public class Productcategory implements Serializable{
/**
*
*/
private static final long serialVersionUID = 7249744975503046565L;
private String shop_cat_id;
private String shop_cat_name;
private String shop_scat_id1;
private String shop_scat_id1name;
private String shop_scat_id2;
private String shop_scat_id2name;
private String shop_scat_id3;
private String shop_scat_id3name;
...Ignore get and set method
}
Second
you can use gson or use a lot of json.getString....
// this is your json,I replace it with ""
String jsondata="";
Gson gson = new Gson();
JsonParser parser = new JsonParser();
JsonArray Jarray = parser.parse(jsondata).getAsJsonArray();
ArrayList<Productcategory> pc_list= new ArrayList<Productcategory>();
for (JsonElement obj : Jarray) {
Productcategory pc = gson.fromJson(obj, Productcategory.class);
pc_list.add(pc);
}
Third
Now,you get a list,you can use it for your ListView and if you want to click the item,
you should use pc_list.get(position) to get a Productcategory,so you can fill detail page.
I tried to let you know what I'm saying.But my English sucks.
You can use expandablelistview where your group will be the main category and onclick subcategory will be displayed.
To do this you need to do is create a object of product which contains shop_cat_id,shop_cat_name,... etc and then create a list of this.
Then pass this list to the BaseExpandableListAdapter, since the variable in the object maintain its position in getGroupView set the shop_cat_name to groupview and other three subcategory to getChildView.
you need change your json with following, as you mention in your comment that your sub Category is not fix then you must send one jsonArray as inner of all category. i write one for you:
"Productcategory": [
{
"shop_cat_id": "1",
"shop_cat_name": "kurtis",
"shop_scat_id1": "1",
"SubCategory": [
"cotton kurtis",
"Cotton Designer Kurtis",
"soft Designer kurtis"
]
},
........
// other jsonObject is same
you need handle id number in your code, because you have simple id number that start from 2. if have a problem with that say to me.
Edit
for catching value on SubCategory you must use following code:
JSONObject json = jsonarray.getJSONObject(i);
JSONArray SubCategoryArray = json.getJSONArray("SubCategory");
for (int i = 0 ; i < SubCategoryArray.length() ; i++)
{
map.put( i+1 , SubCategoryArray.getString(i));
// with this code you have title and id of your subCategory in map
// id start from 1 ( i + 1).
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
#Override
protected String doInBackground(String... params) {
try{
JSONParser jParser = new JSONParser();
String url="http://earlykid.com/android/?page=2";
IdArray=jParser.getJSONFromUrl(url);
Log.e("Fetch Data",IdArray.toString());
mLatestList.clear();
for(int i=0;i<IdArray.length();i++){
try{
JSONObject jObject;
mKids=new Kids();
jObject=IdArray.getJSONObject(i);
mKids.SetTotalPages(jObject.getString("totalItems"));
mKids.SetCurrentPage(jObject.getString("currentPage"));
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
Log.e("log_tag", "Failed data was:\n" + IdArray);
}
}
}catch(Exception e){
}
return null;
}
#Override
protected void onPostExecute(String result) {
mProgress.dismiss();
}
When i fetch the data from this code.it shows me error.
Logcat here:-
error parsing data org.json.JSONException: Value {"totalItems":38,"currentPage":"2","items":[{"id":"Atb1lE9_wzk","title":"ABCD Alphabets Song - Songs for Kids","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/Atb1lE9_wzk\/hqdefault.jpg"},{"id":"UXeeSU0QNro","title":"The rich man and his sons story - Animated Stories for Kids","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/UXeeSU0QNro\/hqdefault.jpg"},{"id":"HmiyKDYrELk","title":"Here we go round the mulberry bush - Nursery Rhyme for Kids","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/HmiyKDYrELk\/hqdefault.jpg"},{"id":"9TLnCurMs5c","title":"Old Mac Donald had a farm - Nursery Rhymes for Kids","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/9TLnCurMs5c\/hqdefault.jpg"},{"id":"DPQ_5GR_MMo","title":"Five Little Monkeys jumping on the bed - Nursery Rhymes","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/DPQ_5GR_MMo\/hqdefault.jpg"},{"id":"CvwHp2xFlJw","title":"Rain Rain go away - Nursery Rhyme","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/CvwHp2xFlJw\/hqdefault.jpg"},{"id":"WEVA9iF6i3s","title":"I'm a little teapot Nursery Rhyme with lyrics","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/WEVA9iF6i3s\/hqdefault.jpg"},{"id":"TQHyRssAM5Y","title":"Ten little fingers ten little toes - Nursery Rhyme","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/TQHyRssAM5Y\/hqdefault.jpg"},{"id":"fDGOlmgF1NE","title":"Jingle Bells Christmas Song","category":"Education","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/fDGOlmgF1NE\/hqdefault.jpg"},{"id":"Y83fbhN6FBk","title":"Pussy Cat Pussy Cat where have you been? - Nursery Rhyme","category":"Film","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/Y83fbhN6FBk\/hqdefault.jpg"},{"id":"UuqNHZEIwEI","title":"Thank you for the world so sweet - Kids Song","category":"Film","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/UuqNHZEIwEI\/hqdefault.jpg"},{"id":"g0u1iWUmg8Q","title":"Ding dong bell - Nursery Rhyme","category":"Film","thumbnail":"http:\/\/www.earlykid.com\/android\/timthumb.php?w=600&h=330src=http:\/\/i1.ytimg.com\/vi\/g0u1iWUmg8Q\/hqdefault.jpg"}]
What you are getting is a JSONObject from this url http://earlykid.com/android/?page=2
You have this
IdArray=jParser.getJSONFromUrl(url); // wrong. you get a json object
{ represents a json object node
[ represents a json array node
Your json
{
"totalItems": 38,
"totalPages": 3,
"itemsPerPage": 12,
"currentPage": "2",
"items": [
{
"id": "Atb1lE9_wzk",
"category": "Education",
"title": "ABCD Alphabets Song - Songs for Kids",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/Atb1lE9_wzk/hqdefault.jpg"
},
{
"id": "UXeeSU0QNro",
"category": "Education",
"title": "The rich man and his sons story - Animated Stories for Kids",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/UXeeSU0QNro/hqdefault.jpg"
},
{
"id": "HmiyKDYrELk",
"category": "Education",
"title": "Here we go round the mulberry bush - Nursery Rhyme for Kids",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/HmiyKDYrELk/hqdefault.jpg"
},
{
"id": "9TLnCurMs5c",
"category": "Education",
"title": "Old Mac Donald had a farm - Nursery Rhymes for Kids",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/9TLnCurMs5c/hqdefault.jpg"
},
{
"id": "DPQ_5GR_MMo",
"category": "Education",
"title": "Five Little Monkeys jumping on the bed - Nursery Rhymes",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/DPQ_5GR_MMo/hqdefault.jpg"
},
{
"id": "CvwHp2xFlJw",
"category": "Education",
"title": "Rain Rain go away - Nursery Rhyme",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/CvwHp2xFlJw/hqdefault.jpg"
},
{
"id": "WEVA9iF6i3s",
"category": "Education",
"title": "I'm a little teapot Nursery Rhyme with lyrics",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/WEVA9iF6i3s/hqdefault.jpg"
},
{
"id": "TQHyRssAM5Y",
"category": "Education",
"title": "Ten little fingers ten little toes - Nursery Rhyme",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/TQHyRssAM5Y/hqdefault.jpg"
},
{
"id": "fDGOlmgF1NE",
"category": "Education",
"title": "Jingle Bells Christmas Song",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/fDGOlmgF1NE/hqdefault.jpg"
},
{
"id": "Y83fbhN6FBk",
"category": "Film",
"title": "Pussy Cat Pussy Cat where have you been? - Nursery Rhyme",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/Y83fbhN6FBk/hqdefault.jpg"
},
{
"id": "UuqNHZEIwEI",
"category": "Film",
"title": "Thank you for the world so sweet - Kids Song",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/UuqNHZEIwEI/hqdefault.jpg"
},
{
"id": "g0u1iWUmg8Q",
"category": "Film",
"title": "Ding dong bell - Nursery Rhyme",
"thumbnail": "http://www.earlykid.com/android/timthumb.php?w=600&h=330src=http://i1.ytimg.com/vi/g0u1iWUmg8Q/hqdefault.jpg"
}
]
}
Parsing
try {
JSONObject jb = new JSONObject(myjsonstring);
String totalitems = jb.getString("totalItems");
Log.i("......", "" + totalitems);
String totalpages = jb.getString("totalPages");
String itemsPerPage = jb.getString("itemsPerPage");
String currentPage = jb.getString("currentPage");
JSONArray jarr = jb.getJSONArray("items");
for (int i = 0; i < jarr.length(); i++) {
JSONObject jb1 = jarr.getJSONObject(i);
String id = jb1.getString("id");
String categoy = jb1.getString("category");
String title = jb1.getString("title");
String pic = jb1.getString("thumbnail");
Log.i("........", id);
}
} catch (Exception e) {
}
Try this :
JsonObject oJsonObject = new JSONObject(myjsonstring);
if(oJsonObject.has("items"))
{
oJsonArray = oJsonObject.getJSONArray("items");
for(int i = 0; i < oJsonArray.length(); i++)
{
String id = oJsonArray.getJSONObject(i).getString("id");
String title = oJsonArray.getJSONObject(i).getString("title");
String category = oJsonArray.getJSONObject(i).getString("category");
String thumbnail = oJsonArray.getJSONObject(i).getString("thumbnail");
}
}
Actually in your JSON you have missed a } at the end of JOSN data so it is not a vlid JSON which you have posted over here
I'm trying to create a list of "events" for an agenda.
To do this, I recieve a JSON response which contains several month objects, which in turn contain an array of event-objects.
When I receive my response, all months are ordered, as shown below:
{
"Agenda/Future": {
"November 2011/0": [
{
"id": "5710",
"eventid": "",
"name": "test7",
"startdate": "nov 9",
"datecompute": "2011-11-09T12:00:00",
"group_month": "November 2011",
"flg_Data": "Database"
},
{
"id": "5707",
"eventid": "",
"name": "test4",
"startdate": "nov 17",
"datecompute": "2011-11-17T12:00:00",
"group_month": "November 2011",
"flg_Data": "Database"
},
{
"id": "5704",
"eventid": "",
"name": "test",
"startdate": "nov 30",
"datecompute": "2011-11-30T12:00:00",
"group_month": "November 2011",
"flg_Data": "Database"
}
],
"December 2011/1": [
{
"id": "5705",
"eventid": "",
"name": "test2",
"startdate": "dec 28",
"datecompute": "2011-12-28T12:00:00",
"group_month": "December 2011",
"flg_Data": "Database"
}
],
"November 2013/2": [
{
"id": "5706",
"eventid": "",
"name": "test3",
"startdate": "nov 1",
"datecompute": "2013-11-01T12:00:00",
"group_month": "November 2013",
"flg_Data": "Database"
},
{
"id": "5708",
"eventid": "",
"name": "test5",
"startdate": "nov 15",
"datecompute": "2013-11-15T12:00:00",
"group_month": "November 2013",
"flg_Data": "Database"
},
{
"id": "5709",
"eventid": "",
"name": "test6",
"startdate": "nov 15",
"datecompute": "2013-11-15T12:00:00",
"group_month": "November 2013",
"flg_Data": "Database"
}
]
}
}
First there is November 2011, then December 2011, and finally November 2013.
However after parsing this response, the order has changed to November 2011, November 2013, December 2011.
Like so:
Obviously, this can cause quite some confusion.
My theory is that due to the use of JSONArray eventNames = agenda.names();, which gets the names of the month objects, the order changes to one based on the actual month, not the year. This has been confirmed after adding another event in March 2022, and this event ends up first.
I checked through my code, and nowhere can I find any sort of function that would change the ordering, making the names(); the most probably culprit.
My question is, how can I make sure the objects in my initial JSONArray get ordered by the month + year, rather then just the month. Removing the names() method is not an option, considering the fact that the objectnames for the months are dynamic (based on month+year). I also would rather not change to a different parsing system (GSON, Jackson), since this is the only one that has been succesfull at parsing my reponse (see previous asked questions).
Eventually managed to fix it by looping over an array containing the full names, and then checking whether that name contained any of the parts from the ordered list (the one containing the years + id). If the string contains that part, add it to a new array on the position of the year+id it contained. Code can be found below
String[] test = new String[eventNames.length()];
String[] test2;
for (int x = 0; x < eventNames.length(); x++){
//System.out.println(eventNames.get(x).toString());
String[] xx = eventNames.get(x).toString().split(" ");
test[x] = xx[1];
}
Arrays.sort(test);
String[] test3 = new String[eventNames.length()];
for(int q = 0; q < eventNames.length(); q++){
String str = eventNames.get(q).toString();
for(int p = 0; p < test.length; p++){
if(str.contains(test[p])){
test3[p] = str;
}
}
}
System.out.println(test.toString());
for (int x = 0; x < eventNames.length(); x++){
System.out.println("maand :"+x+" "+test3[x]);
}
I woudl speculate that JSON Object is backed with map, and names does merely Map.keys() - order of keys is undefined. At leas API spec says nothing about any sorting / ordering of individual fields - so you will have to order those entries yourself - defining comparator based on split(" ") is not that difficult
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
}
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.
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
}