我有一個php multidimensional數組,我將它轉換成JSON與php json_encode函數。從php解析json到javascript
現在,編碼後,我回聲的JSON像echo'var javascriptJson ='。$ encoded_in_json_array;
我怎樣才能得到javascriptJson使用JavaScript的值?或者,我怎麼能將我的multidim php數組轉換爲JavaScript,以便我可以遍歷它或獲取值?
javascriptJson看起來像這樣:
var javascriptJson={
"AMERICA CENTRALA SI DE SUD": {
"Argentina": {
"Recomandari pentru toti calatorii: Vaccinari de rutina": {
"Difterie\/Tetanos\/Pertussis": "background-color: b6c86;",
"Rujeola\/Rubeola\/Oreion": "background-color: b1ffff;",
"Varicela": "background-color: ffffff;",
"Gripa sezoniera": "background-color: ffffff;"
},
"Recomandari de vaccinare pentru majoritatea calatorilor": {
"Hepatita A": "background-color: a6a6a6;",
"Tifos": "background-color: d9d9d9;"
},
"Recomandari de vaccinare limitate (in functie de expunere)": {
"Hepatita B": "background-color: 7f7f7f;",
"Rabia": "background-color: 93d;"
},
"Recomandari speciale de preventie": {
"Malaria": "background-color: 9bbb59;"
}
},
"Belize": {
"Recomandari pentru toti calatorii: Vaccinari de rutina": {
"Difterie\/Tetanos\/Pertussis": "background-color: b6c86;",
"Rujeola\/Rubeola\/Oreion": "background-color: b1ffff;",
"Varicela": "background-color: ffffff;",
"Gripa sezoniera": "background-color: ffffff;"
},
"Recomandari de vaccinare pentru majoritatea calatorilor": {
"Hepatita A": "background-color: a6a6a6;",
"Tifos": "background-color: d9d9d9;"
},
"Recomandari de vaccinare limitate (in functie de expunere)": {
"Hepatita B": "background-color: 7f7f7f;",
"Rabia": "background-color: 93d;"
},
"Recomandari speciale de preventie": {
"Malaria": "background-color: 9bbb59;"
}
},
"Bolivia": {
"Recomandari pentru toti calatorii: Vaccinari de rutina": {
"Difterie\/Tetanos\/Pertussis": "background-color: b6c86;",
"Rujeola\/Rubeola\/Oreion": "background-color: b1ffff;",
"Varicela": "background-color: ffffff;",
"Gripa sezoniera": "background-color: ffffff;"
},
"Recomandari de vaccinare pentru majoritatea calatorilor": {
"Hepatita A": "background-color: a6a6a6;",
"Tifos": "background-color: d9d9d9;"
},
"Recomandari de vaccinare limitate (in functie de expunere)": {
"Hepatita B": "background-color: 7f7f7f;",
"Rabia": "background-color: 93d;"
},
"Recomandari speciale de preventie": {
"Malaria": "background-color: 9bbb59;"
}
}, .....etc...etc
也許這可以幫助您的問題: http://stackoverflow.com/問題/ 13994858/javascript-convert-php-json-into-a-javascript-array – csanonymus
通過使用javascriptJson [「美國中部城市」] [「伯利茲」] [「Recomandari speciale de preventi E 「] [」 瘧疾「]'? – h2ooooooo
@ h2ooooooo他需要一個自動的方式來做到這一點... – csanonymus