Search code examples
jsongoogle-mapsgeocodinggoogle-geocoder

How to extract specific elements from the Google Geocoding json response through a URL?


So I want to be able to run this

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address

which returns a json response with many results...

Id like to be able to parse the json from the url itself...

so something like. .... https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&results[0].formatted_address

so that instead of getting a multiline response - I just get what I need in a single line such as...

277 Bedford Avenue, Brooklyn, NY 11211, USA

Sure I can write a script to do this but I wonder if specific fields of the JSON are restful.

Am i talking smack or is this possible ?

Thank You


Solution

  • Although RESTful web services may utilize JSON, the fields of JSON results themselves are not RESTful. Parsing values from the URL would probably require you to change how Google handles url processing on the server end. You'll have to get that information programmatically.