javascript - parsing json not working -


I'm new to JSON and I've used json_encode to create a JSON object that looks like this

  [{ "timestamp": "12 \ / 16 \ / 2013 0:00", "curr_property": "7211", "curr_property_cost": "123", "day_property": "48", " De_proprti_cost ":" 281 "," Kurr_solr_jnareting ":" 4958 "," Kurr_solr_aksport ":" 0 "," De_solr_jnareted ":" 33 "," De_solr_aksport ":" 0 "," Kurr_chanl ":" 1964 "," Kurr_chan2 " : "" "" "" "", "Day": "", "13", "day_chach 2": "33", "day_account 3": "1"}, {"timestamp": "12 \ / \ / 2013 12:00 "16" Kurr_proprti ":" 7179 "," Kurr_proprti_cost ":" 123 "," De_proprti ":" 72 "," De_proprti_cost ":" 281 "," Kurr_solr_jnareting ":" 4926 " "Curr_solar_export": "0", "Day_solar_ge" nerated ":" 49 "," day_solar_export ":" 0 "," curr_chan1 ":" 1980 "," curr_chan2 ":" 4926 "," Krru "" "273", "Din_cn 1": "19", "Din_cn "" "49", "day_account 3": "2"}, {"timestamp": "12 \ / 16 \ / 2013 0:00" "curr_property": "9627", "curr_property_cost": "165" "De_proprti": "104", "De_proprti_cost": "282", "Kurr_solr_jnareting": "4749", "Kurr_solr_aksport": "0", "De_solr_jnareted": "65", "De_solr_aksport": "0", "Kurr_chanl "" "", "" "", "" "", "" "", " ":" 12 \ / 16 \ / 2013 0:00 "," curr_property ":" 9610 "," curr_property_cost ":" 165 "," Din_proprti ":" 136 "," day_property_cost ":" 282 "," curr_solar_generating " : "4781", "curr_solar_export": "0", "day_solar_generated": "81", "day_solar_export": "0", "curr_chan1": "1 9 80", "Krl_kan 2": "4781", "less "" "2849", "day_account1": "32", "day_chan 2": "81", "day_chan3": "21"}, {"timestamp": "12 \ / 16 \ / 2013: 01 "," Kurr_proprti ":" 9691 "," Kurr_proprti_cost ":" 166 "," De_proprti ":" 168 "," De_proprti_cost ":" 283 "," Kurr_solr_jnareting ":" 4797 "," Kurr_solr_aksport ":" 0 " , "Day_solar_generated": "97", "day_solar_export": "0", "curr_chan1": "" "" "" "" "" "" "" "" "" "," 497 "," 3 ":" 2898 "," day_chan 1 ":" 39 "," day_chach 2 ":" 97 "," day_account 3 ":" 31 "}, {" timestamp ":" 12 \ / 16 \ / 2013 0: 01 "," Kurr_proprti ":" 7034 "," Kurr_proprti_cost ":" 120 "," De_proprti ":" 191 "," De_proprti_cost ":" 283 "," Kurr_solr_jnareting "" 4781 "" Kurr_solr_aksport ":" 0 "; "De_solr_jnareted": "113", "De_solr_aksport": "0", "Kurr_chanl": "1980", "Kurr_chan2": "4781", "Kurr_chan3": "273", "De_chanl": "46", "De_chan2 ":" 113 "," day_chan3 ":" 32 "}]  

I tried to parse the data using script below

  $ (document) .ready (function () {var jsonData = JSON.parse ("& lt ;? Php echo $ jsondata; ? & Gt; "; Console.log (jsonData.timestamp [0]);});  

I do not know what I'm doing wrong I javascript in length of 0 by default, so I How do I get the price? $ BTW on Jsondata gives var_dump data

you console.log (JsonData.timestamp [0]); whose original meaning is, find inside the jsonData property timestamp which is an array and obtain the first index.

But the jsonData array is not a timestamp. Paco perhaps: console.log (jsonData [0] should be with some of .timestamp);


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -