0

I'm using the following syntax:

tell application "JSON Helper"
    set Resultado to (fetch JSON from Request)  
end tell

and I get:

{results:{{formatted_address:\"Rua Dr. Carmelo D'Agostino, 628 - Jardim Rincão, São Paulo - SP, 02991-040, Brazil\", partial_match:true, address_components:{{short_name:\"628\", long_name:\"628\", types:{\"street_number\"}}, {short_name:\"Rua Dr. Carmelo D'Agostino\", long_name:\"Rua Doutor Carmelo D'Agostino\", types:{\"route\"}}, {short_name:\"Jardim Rincão\", long_name:\"Jardim Rincão\", types:{\"political\", \"sublocality\", \"sublocality_level_1\"}}, {short_name:\"São Paulo\", long_name:\"São Paulo\", types:{\"administrative_area_level_2\", \"political\"}}, {short_name:\"SP\", long_name:\"São Paulo\", types:{\"administrative_area_level_1\", \"political\"}}, {short_name:\"BR\", long_name:\"Brazil\", types:{\"country\", \"political\"}}, {short_name:\"02991-040\", long_name:\"02991-040\", types:{\"postal_code\"}}}, geometry:{viewport:{northeast:{lat:-23.432391219708, lng:-46.725645019708}, southwest:{lat:-23.435089180292, lng:-46.728342980292}}, location:{lat:-23.4337402, lng:-46.726994}, location_type:\"ROOFTOP\"}, place_id:\"ChIJgVGzRqL7zpQRTQPNqsmBVLY\", types:{\"street_address\"}}}, status:\"OK\"}." number -1728 from item 1 of {results:{{formatted_address:"Rua Dr. Carmelo D'Agostino, 628 - Jardim Rincão, São Paulo - SP, 02991-040, Brazil", partial_match:true, address_components:{{short_name:"628", long_name:"628", types:{"street_number"}}, {short_name:"Rua Dr. Carmelo D'Agostino", long_name:"Rua Doutor Carmelo D'Agostino", types:{"route"}}, {short_name:"Jardim Rincão", long_name:"Jardim Rincão", types:{"political", "sublocality", "sublocality_level_1"}}, {short_name:"São Paulo", long_name:"São Paulo", types:{"administrative_area_level_2", "political"}}, {short_name:"SP", long_name:"São Paulo", types:{"administrative_area_level_1", "political"}}, {short_name:"BR", long_name:"Brazil", types:{"country", "political"}}, {short_name:"02991-040", long_name:"02991-040", types:{"postal_code"}}}, geometry:{viewport:{northeast:{lat:-23.432391219708, lng:-46.725645019708}, southwest:{lat:-23.435089180292, lng:-46.728342980292}}, location:{lat:-23.4337402, lng:-46.726994}, location_type:"ROOFTOP"}, place_id:"ChIJgVGzRqL7zpQRTQPNqsmBVLY", types:{"street_address"}}}, status:"OK"}

now I want to get just the "location" in other words I just want these two values

lat:-23.4952611, lng:-46.6724604

It should be no brainer but I wasn't able to do it myself after several hours trying so anyhelp will be much appreciated!

@vanian taking advantage of your skills (and thanking you very much for it) can you please tell me now how to get:

"02991-040" that appears on the "formatted_address" and also here

{short_name:\"02991-040\", long_name:\"02991-040\", types:{\"postal_code\"}

Best!

1 Answer 1

2

The JSON is converted to AppleScript lists and records

if Resultado's status is "OK" then
    tell location of geometry of item 1 of results of Resultado
        set latitude to its lat
        set longitude to its lng
    end tell
end if
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.