Find info from JSON file

I have inherited some code which uses JSON about which I know next to nothing

The code I have has identified some ‘field names’ from the deserialised data and assigned their values to variables; however, I need to know/understand what all the ‘field names’ are in this data as I need to work with other ‘field names’.

Is there a way I can obtain all the ‘field names’ as this will then enable me to obtain the values assigned to these for me to work with.

Many thanks

When you use the Deserialize JSON activity, it outputs an object of type JsonObject. You can see this in the Properties panel once you have clicked on the activity. The official documentation for the JsonObject class is here: JsonObject Class (System.Json) | Microsoft Learn. It seems the JsonObject is just a collection of key-value pairs. There are some Properties there to retrieve the keys and values and you can iterate through each and write them out.

Please let me know if this is helpful.

Hi @gary.cobden,

There are many ways to achieve this. To avoid duplication, I would suggest you refer this thread. It shows you how to iterate through JsonObject in UiPath.

Thank you for your response

Alas the trouble is I have inherited code and know little about JSON programming

All I have is that the Deserialised JSON has been passed to a variable of type JsonObject and I need to get the available ‘field names’ and values from this variable, but do not know how

Thanks

image001.jpg

Thank you for your response

Alas the trouble is I have inherited code and know little about JSON programming

All I have is that the Deserialised JSON has been passed to a variable of type JsonObject and I need to get the available ‘field names’ and values from this variable, but do not know how

Thanks

Hi,
Deserialize the Json tring and supply a variable(assume variable is “Out_jsonData”) to output and drag a message box activity and pass- Out_JsonData.SelectToken(“field names”) to check.

Attached an example as well. :slight_smile:
ExtractDataFromJson_Exercise.zip (13.0 KB)

Let me try and clarify a bit more my issue.
I have a workflow which has a JObject passed to it as jsonresponse

This is then processed (see below) but has many more fields in it than the rxample below

I need to know how to identify those fields and associated values

Thanks

Could you try this? I am able to view all the fields from my test json file.

Thank you.

Got there - had to use jsonResponse.AsJEnumerable.ToString - but it got me all the information I needed.

Thank you

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