-3
想要遍歷這個routes-> bounds-> legs-> steps和alert(path)。我是使用json的新手,你能告訴我如何做到這一點。提前感謝。在javascript中迭代json
JSON是 -
{"routes":[{"bounds":{"copyrights":"Map data ©2013 Google"},
"legs":["steps":[{"distance":{"text":"1 ft","value":0},
"path":[{"ib":39.049870000000006,"jb":-76.51013}],
"lat_lngs":[{"ib":39.049870000000006,"jb":-76.51013}],
"start_point":{"ib":39.04987000000001,"jb":-76.51013},
"end_point":{"ib":39.04987000000001,"jb":-76.51013}}],
"via_waypoint":[],"via_waypoints":[]}],"status":"OK"}
你的JSON甚至不是有效的。看看這個驗證器:http://jsonformatter.curiousconcept.com/ – 2013-02-18 14:10:31
我從谷歌地圖api v3獲取json的方向,我編輯它來縮短它。所以可能會錯過 – Akash 2013-02-18 14:12:40
@ bux578的一些東西,你只需告訴基本的方法來遍歷routes-> bounds-> legs-> steps路徑並實現「path」array.thanks – Akash 2013-02-18 14:13:50