Hello,
I am working on a script that receives a file from Hazel, determines its GPS location using EXIFTOOL and converts it to decimal values to call the google geocode api for location info in JSON format. I have pieced the script together from examples online.
I have been searching through the forum to find an example that I can understand on how extra certain values from the JSON data.
The first half of the script works as expected and I can use “JSON” Location Helper to get the JSON file.
I can get the first, second, third records etc. but not values inside each record. The first record is usually the formatted_address of the location. This is helpful but I would like to favour points of interest, parks, trail info etc.
I would like to search the JSON file for the specific value using these keys and default to city if none are available.
This is an example of JSON file from google.
I believe this is something simple something very simple but do not think I am searching the correct terms.
{results:{{formatted_address:"Canyonlands National Park, Utah 84532, USA", plus_code:{global_code:"85CGF55H+WH"}, address_components:{{short_name:"Canyonlands National Park", long_name:"Canyonlands National Park", types:{"establishment", "point_of_interest", "transit_station"}}, {short_name:"San Juan County", long_name:"San Juan County", types:{"administrative_area_level_2", "political"}}, {short_name:"UT", long_name:"Utah", types:{"administrative_area_level_1", "political"}}, {short_name:"US", long_name:"United States", types:{"country", "political"}}, {short_name:"84532", long_name:"84532", types:{"postal_code"}}}, geometry:{viewport:{northeast:{lat:38.461120980292, lng:-109.819667019708}, southwest:{lat:38.458423019708, lng:-109.822364980292}}, location:{lat:38.459772, lng:-109.821016}, location_type:"GEOMETRIC_CENTER"}, place_id:"ChIJcWINmO8QSIcRBYifYqyRZwU", types:{"establishment", "point_of_interest", "transit_station"}}, {formatted_address:"Grand View Point Rd, Moab, UT 84532, USA", address_components:{{short_name:"Grand View Point Rd", long_name:"Grand View Point Road", types:{"route"}}, {short_name:"Moab", long_name:"Moab", types:{"locality", "political"}}, {short_name:"San Juan County", long_name:"San Juan County", types:{"administrative_area_level_2", "political"}}, {short_name:"UT", long_name:"Utah", types:{"administrative_area_level_1", "political"}}, {short_name:"US", long_name:"United States", types:{"country", "political"}}, {short_name:"84532", long_name:"84532", types:{"postal_code"}}}, geometry:{location_type:"GEOMETRIC_CENTER", viewport:{northeast:{lat:38.4611096, lng:-109.819628219708}, southwest:{lat:38.4549744, lng:-109.822326180292}}, |bounds|:{northeast:{lat:38.4611096, lng:-109.8200543}, southwest:{lat:38.4549744, lng:-109.8219001}}, location:{lat:38.4578519, lng:-109.8200927}}, place_id:"ChIJb0bEUe4QSIcRumj4B4HcOl8", types:{"route"}}, {formatted_address:"Moab, UT 84532, USA", postcode_localities:{"Castle Valley", "Moab"}, address_components:{{short_name:"84532", long_name:"84532", types:{"postal_code"}}, {short_name:"Moab", long_name:"Moab", types:{"locality", "political"}}, {short_name:"UT", long_name:"Utah", types:{"administrative_area_level_1", "political"}}, {short_name:"US", long_name:"United States", types:{"country", "political"}}}, geometry:{location_type:"APPROXIMATE", viewport:{northeast:{lat:38.8717289, lng:-109.0588149}, southwest:{lat:37.94981, lng:-110.0574079}}, |bounds|:{northeast:{lat:38.8717289, lng:-109.0588149}, southwest:{lat:37.94981, lng:-110.0574079}}, location:{lat:38.5719944, lng:-109.4735066}}, place_id:"ChIJkVfE9H3CR4cRimQaBsHawOA", types:{"postal_code"}}, {formatted_address:"San Juan County, UT, USA", address_components:{{short_name:"San Juan County", long_name:"San Juan County", types:{"administrative_area_level_2", "political"}}, {short_name:"UT", long_name:"Utah", types:{"administrative_area_level_1", "political"}}, {short_name:"US", long_name:"United States", types:{"country", "political"}}}, geometry:{location_type:"APPROXIMATE", viewport:{northeast:{lat:38.4999896, lng:-109.0410581}, southwest:{lat:36.9979031, lng:-111.4122939}}, |bounds|:{northeast:{lat:38.4999896, lng:-109.0410581}, southwest:{lat:36.9979031, lng:-111.4122939}}, location:{lat:37.4634157, lng:-109.7591675}}, place_id:"ChIJ9Tcq0CXRN4cR55BS0_WTG_4", types:{"administrative_area_level_2", "political"}}, {formatted_address:"Utah, USA", address_components:{{short_name:"UT", long_name:"Utah", types:{"administrative_area_level_1", "political"}}, {short_name:"US", long_name:"United States", types:{"country", "political"}}}, geometry:{location_type:"APPROXIMATE", viewport:{northeast:{lat:42.001618, lng:-109.0410581}, southwest:{lat:36.9979031, lng:-114.0529979}}, |bounds|:{northeast:{lat:42.001618, lng:-109.0410581}, southwest:{lat:36.9979031, lng:-114.0529979}}, location:{lat:39.3209801, lng:-111.0937311}}, place_id:"ChIJzfkTj8drTIcRP0bXbKVK370", types:{"administrative_area_level_1", "political"}}, {formatted_address:"United States", address_components:{{short_name:"US", long_name:"United States", types:{"country", "political"}}}, geometry:{location_type:"APPROXIMATE", viewport:{northeast:{lat:71.5388001, lng:-66.885417}, southwest:{lat:18.7763, lng:170.5957}}, |bounds|:{northeast:{lat:71.5388001, lng:-66.885417}, southwest:{lat:18.7763, lng:170.5957}}, location:{lat:37.09024, lng:-95.712891}}, place_id:"ChIJCzYy5IS16lQRQrfeQ5K5Oxw", types:{"country", "political"}}, {formatted_address:"85CGF55H+GX", plus_code:{global_code:"85CGF55H+GX"}, address_components:{{short_name:"85CGF55H+GX", long_name:"85CGF55H+GX", types:{"plus_code"}}}, geometry:{location_type:"ROOFTOP", viewport:{northeast:{lat:38.460161480292, lng:-109.818713519708}, southwest:{lat:38.457463519708, lng:-109.821411480292}}, |bounds|:{northeast:{lat:38.458875, lng:-109.82}, southwest:{lat:38.45875, lng:-109.820125}}, location:{lat:38.4588056, lng:-109.8200444}}, place_id:"GhIJX5xTJLo6Q0ARJtGBm3t0W8A", types:{"plus_code"}}}, status:"OK", plus_code:{global_code:"85CGF55H+GX"}}