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

Schevus
New Contributor III

You can use a Structure snap to flatten a JSON object. You canโ€™t use Splitter on credentials because itโ€™s not an array.

I tried the structure snap and is giving me the same result where i am not able to split the โ€œcredentialsโ€ as it is not an array. Not sure what i am doing wrong.

Schevus
New Contributor III

Did you look at my example?

Sorry. I just saw your reply with example. Will go through it and get back to you. Thanks