Reading values from JSON
Hi ,
I receive below JSON from a https outbound operation
{
"Link": "www.sample.com",
"Practice": [
{
"Node": "Record1"
}
]
}
I am able to read Link as - JSON.%Get("Link")
How can I read Node value ?
Hi ,
I receive below JSON from a https outbound operation
{
"Link": "www.sample.com",
"Practice": [
{
"Node": "Record1"
}
]
}
I am able to read Link as - JSON.%Get("Link")
How can I read Node value ?
You'll use both %Library.DynamicObject and %Library.DynamicArray classes for this. When you do JSON.%Get("Practice") the resulting object is a dynamic array, not a dynamic object, so it works a little differently. Then when you get the first element of the array, you have another dynamic object. Try:
//Get the array Practice set array = JSON.%Get("Practice") //Get item 0 from the array we just got set nodejson = array.%Get(0) //Get the value of Node set node = nodejson.%Get("Node") //Write the value out (or do whatever else you need) write node
Many thanks , it worked