使用App Inventor 2过滤URL JSON结果 [英] Filter url JSON results using App Inventor 2
问题描述
我正在尝试使用App Inventor 2过滤JSON url结果,遵循 here2 ,但我仍然无法正确完成.一次只能得到一个结果.
I'm trying to filter a JSON url results using App Inventor 2, following sample codes from here1 and here2, but I still cannot get it done right. I only get one result at a time.
JSON结果是下图所示形式的数据:
The JSON results are data in the form shown in the following figure:
{
"field1":"alphaNumeric1",
"field2":"aNumber1",
"field3":"DD/MM/YY",
"field4":"HH/MM/SS",
"field5":"https://",
"field6":"aText",
"field7":"aNumber2",
"field8":"alphaNumeric2",
"field9":"aNumber3",
"field10":"alphaNumeric3"
}
JSON URL会不断更新,结果也会不断更新,但这暂时不是问题.我可以通过计时器读取它.
The JSON url is constantly updated, so are the results, but this is not a problem for now. I can get it read by a timer.
问题是从上述结果来看,我需要在应用程序中的标签中解析"field2","field5","field6". 因此,例如,当我输入"aNumber1"以在JSON数据中进行搜索,并将结果保存在标签中时.
The problem is that from the above results, I need to parse "field2", "field5", "field6", in according labels in the app. So e.g., when I input a "aNumber1" to get searched in the JSON data, and have the result in a label.
是否可以使用App Inventor 2完成JSON数据搜索?
Is it possible this JSON data search be done with App Inventor 2?
足够亲切的人,请尽可能提供示例块. 预先谢谢大家!
Anyone kind enough please answer with a sample blocks if possible. Thank you all in advance!
无论我尝试了什么,JSON都无法正确过滤.因此,我要过滤XML中的网址结果.
No matter what I've tried, JSON could not get filtered right. Therefore I'm to filter the url results in XML.
XML结果是下图所示形式的数据:
The XML results are data in the form shown in the following figure:
<results>
<decision>
<alphaNumeric1>ABC1D</alphaNumeric1>
<aNumber1>ABCD</aNumber1>
<aDate>123</aDate>
<doc>HTTP</doc>
<aNumber2>1234</aNumber2>
<alphaNumeric2>TYPE</talphaNumeric2>
<aNumber3>12345</aNumber3>
<aNumber4>1234567</aNumber4>
<aText>SomeText</aText>
<aHour>00:00:00</aHour>
</decision>
.
.
.
<decision>
.
.
.
</decision>
.
.
.
</results>
I have tried to follow the example at here2, but I don't get it right. According to the XML output, what should I put in starTag and endTag, to get a parsing result if I'm searching for e.g. aNumber4 value (= 1234567) ?
有人可以回答吗?
好吧,我正在尝试按照此处3的示例在这里取得一些进展
Well I'm trying to make some progress here following the example at here3.
该XML解析时出现运行时错误这不是格式正确的对列表".
The XML is being parsed with a runtime error "this is not a well formatted list of pairs".
以下是我正在使用的块代码:
Following is the blocks code I'm using:
为什么会这样,因为我遵循的是信件的示例?有任何线索可以解决这个问题吗?
Why is that so, since I'm following the example to the letter? Any clues anyone to solve this out?
推荐答案
好吧,您的积木看起来有点奇怪...
well, your blocks look a little bit strange...
您有一个复杂的列表列表,只需使用做到即可找出使用lookup in pairs
...
you have a complex list of lists, just use Do it to find out, how it looks like after each step of using lookup in pairs
...
它有助于遵循已经提供的链接:
It helps to follow the already provided links:
- 如何使用列表
- 如何使用列表列表(pdf),由 appinventor.org
- 另请参见复杂的列表列表示例
- how to work with lists
- how to work with list of lists (pdf) by appinventor.org
- see also An example of a complex List of Lists
在下面的示例块中,我寻找了第一个<decision>
,并在Label1
中像这样显示了标签aDate
的值
In the example blocks below I looked for the first <decision>
and displayed the value of tag aDate
in Label1
like this
您可能想使用for each in list
循环在不同的<decision>
之间循环....
you might want to loop through the different <decision>
s using a for each in list
loop....
这篇关于使用App Inventor 2过滤URL JSON结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!