Storing the values in JSON output to Data table

Hi @Harsha_Vemula,

There are plenty of ways to achieve this. I agree with @saurabhB that you do not need to convert to a datatable to get count of certain values.

In both approaches you will need the following dependency (to ensure your input string is converted to Json object)
image or the namespace in imports

  1. The datatable approach

    JsonCountValueUnique.xaml (9.6 KB)

  2. The query approach

@saurabhB you can trim down the expression even more as the InputJson is already a json object and you can directly access the first key in this case “value” which is a Jarray without using .SelectToken

In the end this expression should get the same answer

InputJson(“value”).Where(Function(Jobject) Jobject(“Status”).ToString.Equals(“New”)).Count

What is this expression doing?
Your Json Object is InputJson, which contains a key called “value”. Then since this is a json array we can use the Where method to iterate through all possible elements in the array and each element in your json array is again a json object (with a key and value (“Status”:“Value”) so we can then use a condition to check for elements with value equal to “New”/“Deleted”/“Abandoned”. This will result in System.Linq.Enumerable which can be finally queried for count of elements with it.

If you are used to List Comprehensions / Lamda functions in Python this syntax might be easier to understand.

JsonCountValueUniqueShorterMethod.xaml (6.8 KB)

Your Json string :
JsonValueCounts.json (870 Bytes)

A tip for next time is to use the code editor option when you paste your Json string, else the double quotes are not the same and it takes much longer for forum members to resolve your query.