jquery - how to read nested array in JSON from javascript? -


i have json array below.

[ [ "{"category_id":1,"category_name":"cake","image_id":0}", "{"category_id":2,"category_name":"briyani","image_id":6}", "{"category_id":3,"category_name":"indian breads","image_id":0}", "{"category_id":4,"category_name":"tandoori","image_id":5}", "{"category_id":5,"category_name":"seafood delight","image_id":10}", "{"category_id":6,"category_name":"vegetarian","image_id":0}", "{"category_id":7,"category_name":"curry","image_id":0}", "{"category_id":8,"category_name":"biryani","image_id":0}", "{"category_id":9,"category_name":"dessert","image_id":13}", "{"category_id":10,"category_name":"chefs recommendation","image_id":0}", "{"category_id":11,"category_name":"beverages","image_id":11}", "{"category_id":12,"category_name":"alcohol","image_id":4}", "{"category_id":13,"category_name":"buffet","image_id":0}" ], [ "{"subcategory_id":1,"category_id":12,"subcategory_name":"beer","image_id":0}", "{"subcategory_id":2,"category_id":12,"subcategory_name":"wine","image_id":0}" ], [ "{"sub_id":1,"category_id":12,"subcategory_name":"beer","image_id":0}", "{"sub_id":2,"category_id":12,"subcategory_name":"wine","image_id":0}" ], 

how read category_name java script? want read category name java script.

var data = { items: [ array1:[ {"category_id":1,"category_name":"cake","image_id":0}, {"category_id":2,"category_name":"briyani","image_id":6}, {"category_id":3,"category_name":"indian breads","image_id":0}, {"category_id":4,"category_name":"tandoori","image_id":5}, {"category_id":5,"category_name":"seafood delight","image_id":10}, {"category_id":6,"category_name":"vegetarian","image_id":0}, {"category_id":7,"category_name":"curry","image_id":0}, {"category_id":8,"category_name":"biryani","image_id":0}, {"category_id":9,"category_name":"dessert","image_id":13}, {"category_id":10,"category_name":"chefs recommendation","image_id":0}, {"category_id":11,"category_name":"beverages","image_id":11}, {"category_id":12,"category_name":"alcohol","image_id":4}, {"category_id":13,"category_name":"buffet","image_id":0} ], array2:[ {"subcategory_id":1,"category_id":12,"subcategory_name":"beer","image_id":0}, {"subcategory_id":2,"category_id":12,"subcategory_name":"wine","image_id":0} ], array3:[ {"sub_id":1,"category_id":12,"subcategory_name":"beer","image_id":0}, {"sub_id":2,"category_id":12,"subcategory_name":"wine","image_id":0} ],] }; 

you can read code snippet:

for(var = 0, l = data.items.array1.length; < l; i++) {     var local_category_name = data.items.array1[i].category_name; } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -