cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

JSON Splitter

mohit_jain
New Contributor

Hi Snaplogic Community

I have a reequipment where I need to fetch the data from the API and split the all the JSON object but we have a large JSON which we cant do it manually I just need any functional part where it will work without any manual work.

Here I am just giving one example:

We have splitter the entity JSON and the result is this . Here are so many object which we need to break.

mohit_jain_0-1705995236453.png

The result I just want is

 

customer_resourceNamecustomercurrencyCodecampaign_resourceNamecampaign_statusadGroup_resourceNameadGroup_status
11AA11AA11AA
22BB22BB22BB
33AA33AA33AA
44BB44BB44BB
55AA55AA55AA
66BB66BB66BB

Can anyone help me in this.
@alchemiz @tlikarish @SpiroTaleski 

Thanks in advance 

 

2 REPLIES 2

koryknick
Employee
Employee

@mohit_jain - I had a similar request from another SnapLogic employee to flatten the incoming JSON document to remove the object nesting.  This is actually a fairly complex request to solve within the SnapLogic expression language since multi-statement logic isn't allowed.  However, I was able to solve it using an expression library, some simple recursion, along with some array and object methods and the jsonPath function.  While the expression used to actually do the work is complex, the call to the expression library function is quite simple.  

Download the attached ZIP file, decompress it, and upload the object.expr as an Expression Library reference in your pipeline: 

koryknick_0-1706035977983.png

Then setup your Mapper as follows to flatten your object as desired:

koryknick_2-1706036087706.png

I would normally provide more detail about how this works, but the description of the flatten() method used here is much more complicated that I can briefly describe in a post.

Hope this helps!

 

 

 

Thank you so much @koryknick 
It really worked for me Thanks for looking into this.