I need help about JSON in spinner list

Hello community members,

I need help about my app, i need put in two spinners ( states and cities ) but in my country has 5500 cities and i get JSON with all cities, well…
Now i need when user click in spinner states list and choose any state in spinner, show all cities in sppiner city.
How i can setup this config, i use extension JSON Tools, but i have no idea how i can use it in my code.

1 Like

You need to show an example of your json…

1 Like

Look like this, but i have no idea how i will start…

this is an example of your blocks, which is fine, however @TimAi2 asked about an example of your json data

Taifun

wow, sorry

json link: https://getjob.info/JSON/estados-cidades.json

States is a initials name and down is cities.

I need put all name in list on spinners…

Thanks.

This gets you a list of states, which can be added as elements to the first Spinner:
(sorry, happen to be working in App Inventor at the time…)

Will take a bit more work to then provide the cities for each state (but working on it…)

1 Like

Here you are. We use the Selection Index from the 1st spinner to present the city list in the 2nd spinner, and global variables for states and cities

The difficult part is the way the json is presented back to AI2/Kodular?, everything seems to be in the wrong order! This certainly works in Ai2, hope this works for you in Kodular.

I will copy your blocks, and test here, soon i will post screen…

Ok, and if use the sequence numbers to get and show to fix wrong order…it’s possible?

Wow, it is incredible, thanks so much TimAi2 you help me a lot.
The Kodular community is great.
Yes, cities is so much to get result in list, but i have certain you is able to it…

Thanks

Thanks, it’s works!

But i get this error when i open screen:

But i don’t close the screen and work, states and cities ok…

Creator not loading for me at the moment (too many connections), but will test when I can…

Hello,

Look around my blocks:

Now i can get states and cities, but before i receive this error:

use Do it to debug your blocks
Unbenannt
see also tip 4 here App Inventor: How to Learn | Pura Vida Apps

Taifun

@claujs

I am sorry, I have not been able to login/connect to Kodular Creator for the last 24 hours, therefore unable to test things. Hopefully by 3rd January, connection issues will be resolved.

Have now been able to test with Kodular, works fine for me. I attach my working aia

K-StatesAndCities.aia (30.2 KB)

1 Like

Thanks!!

I found the error, i just put in Spinner “elements from string” on Designer mode the name: States, when screen open, blocks try get the name “states” and showed error with results 0, because “states string” dons’t exist in my JSON list.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.