JSON STRING

Hi,

I am trying to read a JSON op file. Below is my JSON op.

“Workstation_Patches”: {
“KB4103731”: {
“StatusDetails”: “Patch not installed”,
“Status”: 1
},
“KB4103729”: {
“StatusDetails”: “Patch not installed”,
“Status”: 0
},
“KB4022405”: {
“Status”: 1,
“StatusDetails”: “Update”,
“Value”: {
“value”: “/Date(1499711400000)/”,
“DateTime”: “Tuesday, July 11, 2017 12:00:00 AM”
}
},
“KB4487038”: {
“Status”: -1,
“StatusDetails”: “Security Update”,
“Value”: {
“value”: “/Date(1551724200000)/”,
“DateTime”: “Tuesday, March 5, 2019 12:00:00 AM”
}
},
“JK45454”: {
“StatusDetails”: “Patch not installed”,
“Status”: 1
},
“KB4034662”: {
“Status”: 1,
“StatusDetails”: “Security Update”,
“Value”: {
“value”: “/Date(1502649000000)/”,
“DateTime”: “Monday, August 14, 2017 12:00:00 AM”
}
},
“KB4489871”: {
“Status”: -1,
“StatusDetails”: “Security Update”,
“Value”: {
“value”: “/Date(1553020200000)/”,
“DateTime”: “Wednesday, March 20, 2019 12:00:00 AM”
}
},
“KB4487327”: {
“Status”: -1,
“StatusDetails”: “Security Update”,
“Value”: {
“value”: “/Date(1551205800000)/”,
“DateTime”: “Wednesday, February 27, 2019 12:00:00 AM”
}
}
},

Is there any way I can retrieve the subnodes such as - KB4103731 , KB4489871 , JK45454 etc only whose status is 0?? I can have scenarios where in the subnodes under the root nodes can be completely dynamic and I would need to retrieve that particular sub node only when the Status of that sub node is 0.

HI @shreyaank

This can be easily done by converting your JSON to a datatable. Check out the below post on how you can convert a Json to a datatable

Once you have converted, then you can use datatable filtering to get the required data as you need by filtering using the status. For filtering, you can use Filter Data Table activity…

Hope this helps!!

1 Like

Hi Lahiru,

I tried the solution that is provided in the link, below is the error obtained. Can you please help?

1 Like

HI @shreyaank

Looks like there is a format issue with the JSON string you are passing.

Check this example which is from different site though. but thought of sharing because it looks helpful in solving your problem.

Make sure your JSON is structured in that way mentioned in the link :slight_smile: