Author Message
JanPetersen
Joined: Mar 18, 2015
Messages: 33
Offline
Hi DevConnect

I have not been able to find any thing in developer guide.

I need guidance how to use JSON Parser in OD

I have this example:

{
"phoneNumbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888"
},
{
"type" : "home",
"number": "0123-4567-8910"
}
]
}

Is it possible to get the number key where "type" is "home"

Path Constant in JSON Parser

Something like phoneNumbers/"type"="home"/number

Result = 0123-4567-8910

Please advice

Regards
Jan


WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Attached the the sample app that works on your JSON string.
Filename SampleJSONParserApp.zip [Disk] Download
JanPetersen
Joined: Mar 18, 2015
Messages: 33
Offline
Thanks Wilson

That was helpful

*1 Could you provide a document that explains the use of the "JSON Parser" ?

*2 I have this output with Square brackets [ ]
I need to get the "False" value of the "Value" in array with "name" = "Key1"

How do I do that?

[
{
"id": 8,
"name": "Menu01",
"parameterGroupRefId": 15,
"childrenGroups": [],
"parameters": [
{
"parameterGroupRefId": 15,
"id": 18,
"name": "Key0",
"componentType": "text",
"dataType": "openInput",
"defaultValue": "0",
"value": "True",
"parameterOptionDefault": [],
"parameterOptionSelected": [],
"valueToUse": "True"
},
{
"parameterGroupRefId": 15,
"id": 19,
"name": "Key1",
"componentType": "text",
"dataType": "openInput",
"defaultValue": "0",
"value": "False",
"parameterOptionDefault": [],
"parameterOptionSelected": [],
"valueToUse": "False"
}
],
"groupEmpty": false
}
]


Regards
Jan
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
We don't have a document. The sample app I provided you should work the best to demo how you first use the parser function to get the array and then loop through each JSON object in the array and you use the parser function to get the item from each JSON object.
You would just do almost the same thing for this JSON string. However, since this string starts with "[", you would have do little tweak before putting it through the parser function to get the first array.
I attached the update app to work with this new string you have. Take a look at the Parse node to see the difference.


Filename SampleJSONParserApp2.zip [Disk] Download
Go to:   
Mobile view