How to get Json value from text file

Hi Team,

I have below json array i want to get result based on input variable value
If i give YYY value input i want TestStatus1 value “Ghi”.
If i give XXX value input i want TestStatus1 value “Abc”

Json below ,
Please anyone help me for this

[
{
“Test1” : “XXX”,
“TestStatus1”:“Abc”,
"TestStatus2:“Def”
},
{
“Test1” : “YYY”,
“TestStatus1”:“Ghi”,
"TestStatus2:“Jkl”
},
]

Regards,
Raja G

grafik

Output: myJArray

We assume a single match is to expect:


Last one shows the return, when item is not within the JArray

myJArray.Values(Of JObject).Where(Function (x) x("Test1").Value(Of String).Equals("XXX")).Select(Function (x) x("TestStatus1").Value(Of String)).FirstOrDefault()
1 Like

Hi @ppr ,

I getting error below,
"Where is not member of 'Newtonsoft.Json.Linq.JObject.

Regards,
Raja G

screenshots are done within UiPath immediate panel:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Yes, the error message is valid. But shared code line is using Where from the return of Values(…)

Just share with us your statement / modelling details

Hi @ppr,

I have attached xaml below

JsontoText.zip (2.5 KB)

Hi @ppr ,

Please can u share xmal file .

Regards,
Raja G

grafik

Assign Activity:
myStatus1 =

mjArray.Values(Of JObject).Where(Function (x) x("Test1").Value(Of String).Equals("XXX")).Select(Function (x) x("TestStatus1").Value(Of String)).FirstOrDefault()

For sure you should work with a valid JSON Sample. Find your corrected one here:
Json.txt (158 Bytes)

@ppr Thanks working fine

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