javascript - How to display specific JSON data? -


here json data :

var jsondata =  [ { "month" : "01" },   { "folders" : [ { "name" : "test1" },         { "name" : "test2" },         { "name" : "test3" }       ] },   { "actions" : [ { "id" : "2" },         { "id" : "4" }       ] } ] 

i use json.parse in order transform json text json array (no problems here), , want display month... dosen't work.. why ?

var jsondata = json.parse(jsondata); var month = jsondata.month; alert(month); 

thanks !

supposed

jsondata[0].month; 

your json array of objects. , month 1st item inside array. access value month, point item inside array , try value key.

if json object in format notation have written have worked.

var jsondata = { "month"  : "01",                  "month1" : "02",                  "month1" : "02"                 } 

one of way might be

var jsondata = {},     folders = [{"name" : "test1"}, {"name" : "test1"}, {"name" : "test2"}],     actions = [{"id": "2"}, {"id":"4"}];  jsondata["month"] = "01"; jsondata["folders"] = folders; jsondata["actions"] = actions;  console.log(jsondata); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -