01-22-2024 11:41 PM - edited 01-23-2024 12:45 AM
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.
The result I just want is
customer_resourceName | customercurrencyCode | campaign_resourceName | campaign_status | adGroup_resourceName | adGroup_status |
11 | AA | 11 | AA | 11 | AA |
22 | BB | 22 | BB | 22 | BB |
33 | AA | 33 | AA | 33 | AA |
44 | BB | 44 | BB | 44 | BB |
55 | AA | 55 | AA | 55 | AA |
66 | BB | 66 | BB | 66 | BB |
Can anyone help me in this.
@alchemiz @tlikarish @SpiroTaleski
Thanks in advance
01-23-2024 11:03 AM
@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:
Then setup your Mapper as follows to flatten your object as desired:
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!
01-26-2024 03:23 AM
Thank you so much @koryknick
It really worked for me Thanks for looking into this.