Understanding JSON

WallyDD shanebest at gmail.com
Sun Mar 29 16:39:22 EDT 2009


Hello,

I am trying to geocode some map data using the google maps API.

By using the urllib I can get the JSON output;
http://maps.google.com/maps/geo?q=New+York+USA&output=json&oe=utf8&sensor=true&key=your_api_key

I then read it using;
gmapiresult = json.loads(fg.read())
somedata = gmapiresult['Placemark']

result is; (somedata)
[{u'Point': {u'coordinates': [-73.986951000000005, 40.756053999999999,
0]}, u'ExtendedData': {u'LatLonBox': {u'west': -74.25909, u'east':
-73.699793, u'north': 40.917498999999999, u'south':
40.477383000000003}}, u'AddressDetails': {u'Country': {u'CountryName':
u'USA', u'AdministrativeArea': {u'AdministrativeAreaName': u'NY',
u'Locality': {u'LocalityName': u'New York'}}, u'CountryNameCode':
u'US'}, u'Accuracy': 4}, u'id': u'p1', u'address': u'New York, NY,
USA'}]


Can I further refine the data in "somedata" or am I reliant on string
manipulation?
all I need to get is the data in "coordinates".

I am not sure if this is a json problem or if I don't understand lists
well enough.

Thanks for any help.




More information about the Python-list mailing list