i need help in parsing a json array with javascript .
var data={
"root_name": {
"0": "400",
"1": "test coupon by ashutosh",
"2": "90",
"3": "1",
"4": "2",
"5": "",
"6": "test coupon by ashutosh test coupon by ashutosh test coupon by ashutoshundefined",
"7": "",
"8": "2",
"9": "1",
"10": "50",
"11": "0",
"12": "0",
"13": "0",
"14": "",
"15": "0",
"16": "0",
"17": "1",
"18": "0",
"19": "Test Store",
"20": "0",
"21": "test coupon by ashutosh test coupon by ashutosh",
"22": "250002",
"23": "0",
"24": "1",
"25": "2017-03-14 00:06:07",
"26": "",
"27": "",
"id": "400",
"title": "test coupon by ashutosh",
"user_id": "90",
"category_id": "1",
"subcategory_id": "2",
"image": "",
"description": "test coupon by ashutosh test coupon by ashutosh test coupon by ashutoshundefined",
"tags": "",
"duration": "2",
"charges": "1",
"fixed_rate": "50",
"hour_rate": "0",
"buy_one": "0",
"straight_price": "0",
"straight_off": "",
"was_price": "0",
"now_price": "0",
"coupan_type": "1",
"no_of_view": "0",
"business_name": "Test Store",
"no_like": "0",
"advice": "test coupon by ashutosh test coupon by ashutosh",
"zipcode": "250002",
"chk_add": "0",
"status": "1",
"post_date": "2017-03-14 00:06:07",
"lat": "",
"lon": ""
}
}
this is how i'm trying to parse the above json array with javascript
var jsonData = JSON.parse(data);
alert(jsonData.root_name.length)
for (var i = 0; i < jsonData.root_name.length; i++) {
var counter = jsonData.root_name[i];
alert(counter.id);
}
Here i'm getting jsonData.root_name.length as undefined also unable to parse the array .
Can anyone please guide how to make this work?