cancel
Showing results for 
Search instead for 
Did you mean: 

Removing a column from JSON array

matt_bostrom
New Contributor II

Hello. say i have the following JSON:

e1b2db29411d10c43210ac3f1854102605a2c9f1_1_690x238

how can i remove one of the attributes / columns? Let’s say in the top left from the image above I want to remove the OwnerEmail value from that array… how could i do that in snaplogic? i’ve tried remapping but that breaks the grouping.

9 REPLIES 9

robin
Former Employee

@matt.bostrom, use a Mapper, with Pass-Through enabled and with the field you wish to exclude/delete mapped to an empty Target Path:

image

matt_bostrom
New Contributor II

hi @robin. the catch is (that i probably should have mentioned) is i am grouping the rows by the OwnerEmail b/c further down the pipeline I email the user 1 single email with an HTML Table email snap. The table loops through the $group variable. While the Group By Fields I set the OwnerName like so… the subgrouping $groupBy still contains the field that I grouped by that I don’t want in the html table in the email.

image

here is what my json looks like (i blurred out the real emails but you can see the structure and the group part where i want to remove the owneremail value):

image

The thing to delete in the Mapper is interpreted as a JSON-Path. In Robin’s example, it’s just a top-level property in the document. But, you should be able to use a path like the following to walk an array and delete the property in all the objects in the array:

$group[*].OwnerEmail

So, this path will walk through all the elements in the ‘group’ array (the $group[*] part) and delete the ‘OwnerEmail’ properties.

matt_bostrom
New Contributor II

Got it. That worked for me! Thank you both for the help.