I'm drawing a blank with the best way to process JSON data which will be of the following form:
[{"latlng":"42.6674996,-71.1786423"},
{"latlng":"53.8136722,-1.7301123"}]
var p = '[{"latlng":"42.6674996,-71.1786423"},
{"latlng":"53.8136722,-1.7301123"}]',
It will also be of variable length.
I'm having trouble looking through all the data pairs pulling off the latlng values.
I'm using the code:
for (var key in p) {
if (p.hasOwnProperty(key)) {
alert(key + " -> " + p[key]);
}
}
from this other SO question: How do I loop through or enumerate a JavaScript object?
However, the formats in the above example are different from mine.
How do I loop through each key/value in turn until the JSON string is exhausted?
I'm a little new to JSON and Javascript.