Greetings to the whole community
I’m enzo and I try to create an app for IOS.
I have the result of a call WEB_API the following OUTPUT:
{“Number” 3, “result”: [{“id”: “1”, “company”, “Pastarella”, “latitude”: “00.608315”, “longitude”: “00.454391”, “kilometers”: " 7.000 “}, {” id “:” 2 “,” company “:” Franco P.za Ugo “,” latitude “:” 00.602234 “,” longitude “:” 00.507638 “,” kilometer “:” 7.000 "}, {“id”: “3”, “company”, “Clock”, “latitude”: “00.625584”, “longitude”: “00.383393”, “kilometers”, “7000”}], “status”: “OK” }
I would like to put the 3 results in a list.
with the following cycle I get only the first company then the cycle is interrupted.
How can I get what was asked.
Obviously I tried to put the data in a list but without result.
I thank you in advance for the help.
Hi,
- Do not use Alert in cycles. To check the values of variables, you can create a helper list or a variable, which is then displayed in the auxiliary Label
- First, try without a loop to get all three records from the JSON array, changing their index
- After successfully retrieving the data on the index, create a loop and all the data from JSON array to the list.
- Display this list using the List Viewer
I’ve already tested that if I manually change the get # I can get the results.
The problem is that I can not get the list of companies to put in the listView, the number could be 1,2,3,4,5 … 100
thanks in advance for the help.
get # when using JSON is not used (this block sometimes produces incorrect indexes in the test live). Show me a block that shows the name of the company with index 2.
Do you understand that your JSON data is an array of objects? But in your code, I do not see a block that returns data on an index from this array.
By the way, your JSON data contains an errors. This is an incorrect JSON format with which the Thuinkable X object will not work correctly.
I apologize but I was busy for work,
Here is an image of how I get the company name,
just replace the number at the bottom of the get #
if I apply this technique with a for loop I do not get the desired result.
(I apologize for the language but I translate with google).
The problem is the following. The service gives you data in an incorrect JSON format, and you are trying to read this format using blocks that are designed to work with the correct JSON format.
Now I will try to work with these bad data manually.
If you give me a link to your project, then I’ll try to solve the problem.