Get value from json array

Hi i m trying to get value from json array

[
{
“id”: “202207746”,
“OrderHeaderKey”: “202202542746”
}
]

I am trying to get orderheaderKey ,but facing null pointer exception .Please help.

Post the picture of the workflow from where you are trying to extracting the information

I think you have a similar requirement like here How to extract specific data from a JSON payload using SelectToken? - #6 by marian.platonov

Should i have to put something like this DeserializedArray.SelectToken(“[0].OrderHeaderKey”).ToString ?

this is the response from Http request …after deserialising json array i get the about output . From that i need orderheaderkey

Hi @tharani.natarajan

You can try with Regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=OrderHeaderKey”:\s“)\d+").Tostring

image

Check out the thread for reference

https://forum.uipath.com/search?q=%20Get%20value%20from%20json%20array%20

Regards
Gokul

2 Likes

From your sample we do see an array with only 1 item. So we can do:

grafik
Line2 - e.g. for a looping, when more items are present

We recommend to prefer JSON processing for JSON data over String processing e.g. Regex

DeserialiseJsonArrayOutput(0)(“OrderHeaderKey”).tostring worked

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