How to check Json array for field

Hello all,

I’m looking to see if anyone has some guidance on how to address an issue I have with some json data I’m receiving from an Http request. I am receiving a json array from a vendor and I need to loop through the array to find if it contains a specific document. This array contains all the documents attached to an account. I have deserialized the array and, using a for each, am able to look for the specific document name I need.

The issue I run into occurs when there is not an attachment to a document name. This is what it looks like when there is an attachment. If there is not the “document” section is just missing.

Here is what it looks like when the document is missing:

I have tried various IF statements and they always return a false. If I juse the SelectToken statement, I get "Value cannot be null (Parameter ‘source’).
I saw mention of using ContainsKey, but that doesn’t work as my for each argument is Newtonsoft.Json.Linq.JToken.

Here is a picture of my current process. Any suggestions would be greatly appreciated.


Did you try using IsNothing(currentitem("Document"))

This should give true when document is not there

Can you try and let us know please


set the For each type Argument to JObject, when every item in the array is a JObject, so ContainsKey method will be offered.

If possible share the JSON (redact the / anonymize sensivtive values) Data as Textfile with us so we can used it for solution option checks. Thanks

1 Like

Hi @Anil_G,

I tried that as well and it never returned anything.

Thanks @ppr . I knew it was something I was missing as I rarely have to change the Argument type. Once I changed my For each to Newtonsoft.Json.Linq.JObject it started to work. I did notice a very odd thing through, the field names were coming across different than what I would see in Postman. In Postman, the “document” field comes across as “assignedTo”, and the “attachmentId” is “Id”. I know there may be no reason why for this but wanted to put it out there in case anyone else has odd issues like that. Always good to thrown in write lines when debugging oddities.

Thanks again.

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