How to check if my object contains a specific array

Hi Everyone,

Below is my object. I have my JsonObject defined as Json
{“Details”:[{“Error”:[{“Code”:“A”,“Type”:“E”,“Text”:“No Data”}]}]}

I am trying to check if my Details object has an array called Error.
I tried to use contains. I gave my expression like below

Eventhough it has an Error array, it is always returning False. Could someone please help how to check if my Object contains an Error arroy or not?

Thanks in advance,

@Sam24 - pls try below …

  • add package to your project dependencies
    create a variable type as JObject - ex: jsonResult
  • jsonResult = JObject.Parse(jsonText) - assuming above mention json assigned to jsonText variable

-jsonResult(“Details”)(0).Contains(“Error”) - it will return boolean

@GBK` I tried as you mentioned. I deserialized my output and stored it in the variable named Json. Then I gave my expression as – Json(“Details”)(0).Contains(“Error”). It is returning boolean but it is always returning false eventhough my output contains an array called “Error”. I am not sure why?

@Sam24 I guess you need to Convert it to String before using Contains as it will be in it’s Object State, in this way :

@Sam24 - pls log only Json(“Details”)(0).ToSring this part and check - is it returning the error string. If its returning the value as expected.
strError = Json(“Details”)(0).ToSring
try with strError.Contains(“Error”)

@GBK @supermanPunch - Thanks for the response. Converting it to string did not work for me. Still returning false even the Error array exits.