JSON - How to get a Child value
Divyashree Muddagangaiah
RPA Tech Lead, 3*UiPath MVP(2024,2023,2022), UiPath Community Moderator, Certified ABBYY Developer - FlexiCapture and Vantage. UiABA Certified
Recently I had come up with one scenario which contains a nested JSON elements. which had multiple inner nodes to get a value.
As any other developer does I started deserialization and also started with complex varieties if Solutions like - deserialization array objects, deserialization with looping of each object and try to get inner object using loop and list goes on trail and error based for two days.
When the deadline hits!! all of our brain cells will Start working smart :D It was very simple solution as mentioned below.
IF its a simple JSON - Input your JSON String use deserialization Activity and get the JSON Object Example :
{ ? result : Value?}
We can get a value as output_obj("result").ToString
If Our JSON has nested nodes:
{ ? result :
{ response :
{variables: Value?}
output_obj("result")("response")("variables").ToString
It does not matter how many nodes has been nested we can get the values by using deserialization output Obj and pass the child names just as shown above and we will get the result.
UIPATH, Automation Anywhere, Power Automate, Power App, Power Bi, Python, SQL
3 年Useful
Tech Lead || 2*UiPath MVP ||Top Process Automation Voice ??|| UiPath Ai Hackathon runner ||Certified UiPath Community Trainer
3 年Great Work Divyashree Muddagangaiah
Agentic AI + Automation - Helping organizations in building their Agentic AI solutions
3 年Much needed Divyashree Muddagangaiah