Extract information from json

googlemaps

#1

Hey guys i need some help in extracting a particular value from json string.
The base is that i am sending a GET request to google maps api. The blocks are

And for these, the received results are

I want to use the location part which is highlighted and this should be then given to the markers block as jsonString i.e. [{ lat: ,lng: }] (Replacing the space with the co-ordinates!) as recognized by the blocks.

Also one more thing the GET request address should contain ‘+’ sign instated of spaces like ‘Mumbai University’ should be edited as ‘Mumbai+University’. So how should this be changed in blocks as the user surely will provide spaces in his address instead of + sign.


Help decoding and using JSON
Json response to Listpicker
Open app knowing the app name
[Free] Special tools extension
#2

This bit is easy…

Just use the replace all block to swap spaces for pluses.

This bit was trickier - or at least I made it hard for myself anyway. I took the example JSON response from the Google Maps developers page and took a closer look at it in JSON Viewer to get a better understanding for how the data are structured.
Once I had done that it was just a “simple” (time consuming!) matter of fetching the right thing from the right list:

I’m sure there’s a more elegant method to do this…but it works! :slight_smile:


Json response to Listpicker
#3

Just did a quick check for the blocks I use in most of my audio streaming apps, your best bet would be to have a look at what the guys at Imagnity have done.
JSON Response on App Inventor is one of the best I’ve come across, and from what I’ve seen, you know what you’re looking for in the JSON results.
Try the blocks out, tinker around a bit, and you should hopefully come up with a solution. It does take a bit of time.

When I can get around to it, and if I’ve got the time, I’ll post the blocks I’m using at the moment.


Json response to Listpicker
Using Android's Geocoder
#4

Sooo much more elegant, thanks @Colin_Lacey! :grinning:


#5

thanks to all !!!
Got it done correctly and have learn’t the approach will use it now for complex parts later on!
@Domhnall @Colin_Lacey


#6

hey @MrLateIndustrialist! So, what did you end up using to the the value given a key?


#7

HI there,

can someone help me , i want to display the picture i got from this json result .
want to display
"https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png",“size”:"large"

image in my set image to block … please help on the block on how to parse this image to app

json result as below

{“results”:{“opensearch:Query”:{"#text":"",“role”:“request”,“startPage”:“1”},“opensearch:totalResults”:“5”,“opensearch:startIndex”:“0”,“opensearch:itemsPerPage”:“30”,“trackmatches”:{“track”:[{“name”:“Stayin Alive Cover (Live Mouv’)”,“artist”:“Electro Deluxe”,“url”:“https://www.last.fm/music/Electro+Deluxe//Stayin+Alive+Cover+(Live+Mouv%27)",“streamable”:“FIXME”,“listeners”:“11”,“image”:[{"#text":“https://lastfm-img2.akamaized.net/i/u/34s/20b457107b934dbcb848a65b21c99ff6.png",“size”:“small”},{"#text":“https://lastfm-img2.akamaized.net/i/u/64s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“medium”},{"#text":“https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“large”},{"#text":“https://lastfm-img2.akamaized.net/i/u/300x300/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“extralarge”}],“mbid”:""},{“name”:"Stayin Alive Cover (Live Mouv)”,“artist”:“Electro Deluxe”,“url”:"https://www.last.fm/music/Electro+Deluxe//Stayin+Alive+Cover+(Live+Mouv)”,“streamable”:“FIXME”,“listeners”:“1”,“image”:[{"#text":“https://lastfm-img2.akamaized.net/i/u/34s/20b457107b934dbcb848a65b21c99ff6.png",“size”:“small”},{"#text":“https://lastfm-img2.akamaized.net/i/u/64s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“medium”},{"#text":“https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“large”},{"#text":“https://lastfm-img2.akamaized.net/i/u/300x300/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“extralarge”}],“mbid”:""},{“name”:"Stayin Alive”,“artist”:“Electro Deluxe”,“url”:“https://www.last.fm/music/Electro+Deluxe//Stayin+Alive",“streamable”:“FIXME”,“listeners”:“5”,“image”:[{"#text":“https://lastfm-img2.akamaized.net/i/u/34s/20b457107b934dbcb848a65b21c99ff6.png",“size”:“small”},{"#text":“https://lastfm-img2.akamaized.net/i/u/64s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“medium”},{"#text":“https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“large”},{"#text":“https://lastfm-img2.akamaized.net/i/u/300x300/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“extralarge”}],“mbid”:""},{“name”:"Stayin Alive (Bee Gees Cover Live)”,“artist”:“Electro Deluxe”,“url”:"https://www.last.fm/music/Electro+Deluxe//Stayin+Alive+(Bee+Gees+Cover+Live)”,“streamable”:“FIXME”,“listeners”:“1”,“image”:[{"#text":“https://lastfm-img2.akamaized.net/i/u/34s/20b457107b934dbcb848a65b21c99ff6.png",“size”:“small”},{"#text":“https://lastfm-img2.akamaized.net/i/u/64s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“medium”},{"#text":“https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“large”},{"#text":“https://lastfm-img2.akamaized.net/i/u/300x300/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“extralarge”}],“mbid”:""},{“name”:"Stayin Alive (Bee Gees Cover Live Vubey)”,“artist”:“Electro Deluxe”,“url”:“https://www.last.fm/music/Electro+Deluxe/_/Stayin+Alive+(Bee+Gees+Cover+Live+Vubey)",“streamable”:“FIXME”,“listeners”:“1”,“image”:[{"#text":“https://lastfm-img2.akamaized.net/i/u/34s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“small”},{"#text":“https://lastfm-img2.akamaized.net/i/u/64s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“medium”},{"#text":“https://lastfm-img2.akamaized.net/i/u/174s/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“large”},{"#text":“https://lastfm-img2.akamaized.net/i/u/300x300/20b457107b934dbcb848a65b21c99ff6.png”,“size”:“extralarge”}],“mbid”:""}]},"@attr”:{}}}


#8

How to work with Lists by Saj
How to work with Lists and Lists of lists (pdf) by appinventor.org
JSON and list of lists: example1 and example2

Taifun