How do you use JSON decode with Google Maps API?

181 views
Skip to first unread message

Team DCM

unread,
Oct 18, 2016, 11:17:35 PM10/18/16
to MIT App Inventor Forum
I'm having issues trying to use the JSON Text Decode function in AI2.
I'm trying to use Google Maps to get the distance between 2 lat/long points so I've got the response
I know that I have to use the look up in pairs function but I can't figure out how to get the elements such as 'text' under 'distance' - I keep getting the error 
"Lookup in pairs: the list (((elements(((distance ((text 0.8 mi) (value 1243))) (duration ((text 6 mins) (value 334))) (status OK)))))) is not a well-formed list of pairs"


 











































I assume I'm doing something wrong in this bit above, any help would be greatly appreciated.

Thank you in advance.

Taifun

unread,
Oct 19, 2016, 9:00:01 AM10/19/16
to MIT App Inventor Forum
use Do it to debug your blocks, see tip 4 here

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Taifun

unread,
Oct 19, 2016, 10:33:03 AM10/19/16
to MIT App Inventor Forum
I know that I have to use the look up in pairs function but I can't figure out how to get the elements such as 'text' under 'distance' - I keep getting the error 
"Lookup in pairs: the list (((elements(((distance ((text 0.8 mi) (value 1243))) (duration ((text 6 mins) (value 334))) (status OK)))))) is not a well-formed list of pairs"

rows is a list, see the [ bracket, which means, you have to use additionally the select list item block (to select for example the first item) 
Taifun

Taifun

unread,
Oct 19, 2016, 10:36:59 AM10/19/16
to MIT App Inventor Forum
Reply all
Reply to author
Forward
0 new messages