Formula in handling json


#1

hi ,i’m chen i am poor in handling extracting data from json with formula:

{
“title”:
{
“xxx_1”:{
“name”:“xxx_1”,
“type”:“Variable”,
“value”:null
},
“xxx_2”:{
“name”:“xxx_2”,
“type”:“Variable”,
“value”:“value_xxx_2”
}
}
}

now,i only know the key “title” and the name is “xxx_2”,
how can i get the value------"value_xxx_2"
Thanks.


#2

You can use ‘Deserialize json’ activity, it can look like this:

image

Json variable type: Newtonsoft.Json.Linq.Jobject

To get value use:

Json.Item(“title”).Item(“xxx_2”).Item(“value”).ToString

Hope it helps.


#3

but now i don’t know the key is “xxx_2”,How to locate to json xxx_2


#4

but now i don’t know the key is “xxx_2”,How to locate to json xxx_2


#5

I don’t understand your requirements but you can loop through JObject (or JToken).

Create variable JToken type:

Newtonsoft.Json.Linqu.JToken

Assign to JToken

image

Create For Each Loop

image

TypeArgument in For each loop should be:

Newtonsoft.Json.Linq.JProperty

That way you can print all items that you need.

xxx_1

xxx_2
value_xxx_2