我需要JSONOBJECT.routingpath.coordinates.length
的长度
我收到了这个网址的回复。
http://193.70.60.44:3000/taxi_server/api/v1.0/taxiroute
来自服务器的响应...
[{
"idtaxiroute": "3",
"routingpath": {
"type": "LineString",
"coordinates": [
[49.9670749, 7.8994591],
[49.9682897, 7.898872900000001],
[49.9682897, 7.898872900000001],
[49.9680662, 7.897596899999999],
[49.9680662, 7.897596899999999],
[49.9689168, 7.897404499999999],
[49.9689168, 7.897404499999999],
[49.9690376, 7.895451],
[49.9690376, 7.895451],
[49.9688003, 7.891565000000001],
[49.9688003, 7.891565000000001],
[49.966386, 7.888530899999999],
[49.966386, 7.888530899999999],
[49.9651325, 7.8884534],
[49.9651325, 7.8884534],
[49.9411728, 7.912222499999999],
[49.9411728, 7.912222499999999],
[49.9391022, 7.9152532],
[49.9391022, 7.9152532],
[49.9337381, 7.9157891],
[49.9337381, 7.9157891],
[49.9241653, 7.829844099999999],
[49.9241653, 7.829844099999999],
[49.9259564, 7.8275102],
[49.9259564, 7.8275102],
[49.922877, 7.8259417],
[49.922877, 7.8259417],
[49.92355939999999, 7.8055037],
[49.92355939999999, 7.8055037],
[49.9258713, 7.8004553],
[49.9258713, 7.8004553],
[49.9262293, 7.7978919],
[49.9262293, 7.7978919],
[49.92596469999999, 7.795387600000001],
[49.92596469999999, 7.795387600000001],
[49.9216437, 7.7577913],
[49.9216437, 7.7577913],
[49.91755209999999, 7.7473702],
[49.91755209999999, 7.7473702],
[49.9107566, 7.726173299999999],
[49.9107566, 7.726173299999999],
[49.9115306, 7.725327200000001]
]
},
"taxiid": 551,
"riderequestid": 7
}, {
"idtaxiroute": "4",
"routingpath": {
"type": "LineString",
"coordinates": [
[49.9670749, 7.8994591],
[49.9670378, 7.899477099999999],
[49.9670378, 7.899477099999999],
[49.9651449, 7.898171800000001],
[49.9651449, 7.898171800000001],
[49.9645179, 7.894035400000001],
[49.9645179, 7.894035400000001],
[49.9605222, 7.893961699999999],
[49.9605222, 7.893961699999999],
[49.95326799999999, 7.902490999999999],
[49.95326799999999, 7.902490999999999],
[49.9518747, 7.9065943],
[49.9518747, 7.9065943],
[49.9495675, 7.907795699999999],
[49.9495675, 7.907795699999999],
[49.9479066, 7.9125997],
[49.9479066, 7.9125997],
[49.9405005, 7.910934200000001],
[49.9405005, 7.910934200000001],
[49.9400513, 7.9114172]
]
},
"taxiid": 551,
"riderequestid": 7
}]
代码:
for(var i = 0; i < JSONOBJECT[i].routingpath.length; i++)
{
console.log("Type: " + JSONOBJECT[i].routingpath.coordinates[i][i]);
console.log("Types: " + i);
}
你能帮助我吗?
答案 0 :(得分:1)
在计算使用JSONOBJECT[i]
的{{1}}循环限制时使用for
是没有意义的。
您需要嵌套循环,一个用于i
数组,另一个用于JSONOBJECT
。
coordinates