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โ€