[]JSON
{}0
{}1
...
{14}
name : "pk_ID"
data : "108"
...
I would like to get the value of pk_ID which is 108, but I just can’t :-(.
I understand that the JSONItem is an array of Dictionary (or something else ?) . SO I do something like that (maybe in error):
Dim dictField As Xojo.Core.Dictionary
Dim AuFields As Auto
dictField = xojo.data.ParseJSON(record.ToString.ToText)
AuFields = dictField.Value("field")
...
I query a FileMaker database using XFM from Tim Dietrich, that returns JSONItems.
...
Dim resultset As JSONItem
Dim record As JSONItem
resultset = FMResultSet.Value("resultset")
// This is the contents of resultset
// {
// "count":"1",
// "fetch-size":"1",
// "record":{
// "mod-id":"0",
// "record-id":"119",
// "field":[ ]
// }
//}
//
// I need to work with "field" under record
record = resultset.Value("record")
// This is the contents of record (some data is removed in field because of sensitive data)
{
"mod-id":"0",
"record-id":"119",
"field":[
{
"name":"fk_demande",
"data":"36425"
},
{
"name":"procedureID",
"data":"3719-17"
},
...,
{
"name":"pk_ID",
"data":"119"
},
{
"name":"PDF_image",
"data":""
}
]
}
// Now I need to get the “field” part, and this is where it gets complicated for me.
// I may
Dim field As JSONItem
field = record.Value(“field”)
// Inside field is an array of dictionary, but I can’t find a way to get to the part where name is “pk_ID”.
[code]DIM dict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON(self.TextArea1.Text.ToText)
DIM fields() As Auto = dict.Value(“field”)
for i as Integer = 0 to fields.Ubound
DIM temp As Xojo.Core.Dictionary = fields(i)
if (temp.Value(“name”) = “pk_ID”) then
MsgBox temp.Value(“data”)
end if
next[/code]