How to parse JSON as geo: point?

I am trying to parse a JSON response using jquery from last.fm and get the longitude and latitude values. The part of the JSON that stores these values ​​looks like this:

"location":{"geo:point":{"geo:lat":"58.409901","geo:long":"15.563306"}

The code I received is:

$.getJSON("http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=familjen&api_key=xformat=json&callback=?",
 function(data){
  $.each(data.events.event, function(i,item){
   $("#menucontent").append("<br/>"+item.title + " " + item.venue.location.geo:point.geo:lat);
        });
});

Obviously, the "item.venue.location.geo: point.geo: lat" detail does not work. How to get these values ​​using ":"?

+3
source share
1 answer

You can use a notation bracket when identifiers cannot be expressed in dot notation , it will look like this:

item.venue.location["geo:point"]["geo:lat"]

To illustrate, these are all ways of accessing the same thing:

obj.thing.prop
obj.thing["prop"]
obj["thing"]["prop"]
obj["thing"].prop
+6
source

Source: https://habr.com/ru/post/1772388/


All Articles