How to extract the key value based on a JSON payload?

Please help to get key where “IsLatestVersion”: true

input - {
@odata.context”: UiPath,
@odata.count”: 2,
“value”: [
{
“Key”: “f943f755-9553-46a8-bfd768”,
“ProcessKey”: “Fedex_Retail_Claim_Process”,
“IsLatestVersion”: false,
“Name”: “Retail_Claims”
},
{
“Key”: “3e7c8a6d-872c-4edbf60d790”,
“ProcessKey”: “Fedex_Retail_Claim_Process”,
“IsLatestVersion”: true,
“Name”: “Fedex_Retail_Claim_Process”
}
]
}

Output:
3e7c8a6d-872c-4edbf60d790

You can try this approach:

  1. Make sure that the JSON payload is correct. You can use https://jsonformatter.org/json-pretty-print for that.

  1. Add the UiPath.WebAPI.Activities in your project dependencies.

image

  1. Save the payload to a txt file.

image

  1. Read the Text File.

  1. Deserialize JSON.

  1. Use a Write Line to display the IsLatestVersion.
jsonPayloadObject.SelectToken("$.value.[1].IsLatestVersion").ToString()

  1. Results → True

image

1 Like

@tharani.natarajan

After deserializing json as mentioned above…please use this in assign

djson("value").Where(function(x) x("IsLatestVersion").ToString.Tolower.Contains("true")).Select(function(x) x("Key").ToString)(0)

image

cheers

Thanks a lot for explanation

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.