Thu Jul 18, 2019 11:40 am
Login Register Lost Password? Contact Us


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: 25
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: 373
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: 373
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: 25
Joined: Mon Jul 11, 2016 12:45 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 0 guests