cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to flatten the hierarchical json

arvindnsn
Contributor

Hello, Below is the JSON output from a REST API source. I am trying to flatten the hierarchical JSON structure using the splitter snap. I am able to flatten “meals” attribute, but unable to split the “credentials”. The expected output should be all the attributes should be column names.

{
“object”: “list”,
“data”: [
{
“id”: “locid”,
“object”: “locname”,
“group_id”: “grp_id”,
“name”: “name1”,
“active”: 1,
“count”: 2,
“timezone”: “xxxx”,
“week_end”: “Wednesday”,
“sales_tax”: 0.0825,
“schedule_start”: “”,
“schedule_stop”: “”,
“type”: “xxxx”,
“meals”: [
{
“name”: “breakfast”,
“end”: “10:30”
},
{
“name”: “lunch”,
“end”: “15:00”
}
],
“credentials”: {
“str_id”: “999999”,
“str_id_2”: “2222”
}
}

1 ACCEPTED SOLUTION

You’ll need to add some element to the meal list when it’s empty in order to get the splitter to do anything. Maybe add an empty object (i.e. {}) or null.

View solution in original post

15 REPLIES 15

The attached example is able to flatten the Credentials attribute. But If you see the output results, It is not bringing any data for the 2nd document (ie Loc_2), since it does not have any meal information

You’ll need to add some element to the meal list when it’s empty in order to get the splitter to do anything. Maybe add an empty object (i.e. {}) or null.

That Worked. Thank You.

tstack
Former Employee

Can you export and attach the pipeline that you have so far so that we can see the configuration of the splitter snap?

Splitjsonobject.slp (13.8 KB)

Uploaded the Pipeline file “splitjsonobject.slp”