I have the next JSON object but I can’t get latitude and longitude from it. In JavaScript every time I try I get undefined error:
{
"response": {
"date_ts": 1352514978,
"raw": {
"profile": "realtime",
"battery": -100,
"battery_state": "unknown"
},
"uuid": "b191d0d4-a967-47c9-b58b-3b491c8247db",
"location": {
"position": {
"altitude": 0,
"speed": -4,
"horizontal_accuracy": 5,
"latitude": 37.785834,
"longitude": -122.406417,
"heading": 0,
"vertical_accuracy": 0
},
"type": "point"
},
"date": "2012-11-09T20:36:18-06:00"
},
"type": "onSuccess",
"source": {}
}
Any advice?
You need to parse the JSON before you can manipulate it as a complex object structure.
DEMO: http://jsfiddle.net/VwWvP/