2017년 6월 1일 목요일

App Inventor JSON Parsing problem


Hello. I have a page with JSON code, for example: 
  "name": "numero_1", "value": 1782
},
{ "name": "numero_2", "value": 1348 
}, 
{ "name": "numero_3", "value": 578
I need to parse it to something like this: 
Numero_1: 1782
Numero_2: 1348
Numero_3: 578
The problem is, there are many "value" tags and when I try startTag "numero_2", "value": and endTag }, It's naturally now working. Is there a way to do this?

--
convert the json into a list of lists, then use the lookup in pairs block
see this example in the WebInfo.GotText event http://puravidaapps.com/oauth.php

--
Thanks, but it's pretty complicated. Isn't there an easier way?

--
actually using the JsonDecode block together with the lookup in pairs block makes it very simple...

--
I cannot see all of your JSON text so I had to do an example with my own.
--
Thanks for the answer. I feel a bit stupid now, but, I don't understand how does it work. So I will show you exactly I need. I upload a file which contains the data in the JSON file. It's from a game on Steam. I just want to take data from it, like "Kills: 213", "Deaths: 213", but the start tag is always "value". Thanks for your help.

JSON.txt

--
starting from what I said previously and the example from Scott should help you to understand how this works...
you might want to try something based on Scott's example and if you get stuck, post a screenshot of what have you tried

--
I don't understand how does it work.
What don't you understand?
As Taifun said, you should try using my example to parse your data file by trial and error if necessary, then come back for help if you still cannot get it to work.

--
I don't undrestand mainly the "list of lists". For what are the index numbers, and how is it all working..

Dňa nedeľa, 30. marca 2014 5:09:24 UTC+2 scottfromscott napísal(-a):


--
right click onto the blocks and select "Do it" to see the result of each step
1. the first step is to convert the json result into a list
2. then the first list item is selected of the list, which has been generated in step 1
3. then the second list item of step 2 is selected

--
So I somehow get it to work with this tutorial: http://www.appinventorblocks.com/appinventor-tutorials-tips/appinventor-web-component-json-response Thanks for help

--
I used this block to get a json response by index number or label. Hope it helps some one.

--
Thanks for sharing, Paul! I like the by index or label options :)

--

댓글 없음:

댓글 쓰기