Sun Aug 07, 2022 4:06 pm
Login Register Lost Password? Contact Us

Please Note: The HPCC Systems forums are moving to Stack Overflow. We invite you to post your questions on Stack Overflow utilizing the tag hpcc-ecl (https://stackoverflow.com/search?tab=newest&q=hpcc-ecl). This legacy forum will be active and monitored during our transition to Stack Overflow but will become read only beginning September 1, 2022.



FROMJSON to DataSet

Comments and questions related to the Enterprise Control Language

Thu May 09, 2019 7:02 pm Change Time Zone

How can I turn the json array into a child dataset verses a SET?

Code: Select all
x := '{"childNames": ["Sasha Obama","Malia Obama"]}';

PersonRec := RECORD
   DATASET({UNICODE name}) childNames {xpath('childNames')};
END;

line := FROMJSON(PersonRec,x);

line;
wjblack
 
Posts: 27
Joined: Mon Jul 11, 2016 12:45 pm

Mon May 13, 2019 3:19 pm Change Time Zone

Hi wjblack,

Divide and conquer:
Code: Select all
x := '{"childNames": [{"FN" : "Sasha"},{"FN":"Malia"}]}';

PERSONRec := RECORD
   STRING FN{xpath('FN')};
END;

PeopleRec := RECORD
   DATASET(PERSONRec) childNames {xpath('childNames')};
END;

FROMJSON(PeopleRec,x);


Yours
Allan
Allan
 
Posts: 444
Joined: Sat Oct 01, 2011 7:26 pm

Mon May 13, 2019 3:41 pm Change Time Zone

In addition, I always find it worth my while to search the Forum on say 'JSON'.
There are other posts that might have helped.

Yours
Allan
Allan
 
Posts: 444
Joined: Sat Oct 01, 2011 7:26 pm

Mon May 13, 2019 7:41 pm Change Time Zone

Thanks for your help. I always do start with a search of the forum.
wjblack
 
Posts: 27
Joined: Mon Jul 11, 2016 12:45 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 2 guests

cron