cancel
Showing results for 
Search instead for 
Did you mean: 

Filter out the specific column

KTsnap
New Contributor III

 to filter out column A if it is null but not other columns

[
{
"Record" : [
{
"Customfields": {
"A" : "",
"B" : "defg"
},
"Name" : "khu"
}
]
}
]

1 REPLY 1

koryknick
Employee
Employee

@KTsnap - I'll solve this with the help of one of my favorite features in SnapLogic: the Mapping root.

Configure a Mapper snap as follows:

koryknick_0-1700483803700.png

The "Mapping root" is widely overlooked but immensely powerful.  It allows you to take action on a subsection of hte input document.  In this case, I want to work only on the objects within the Record array.  By specifying $Record[*] in the mapping root, I can access those objects as if they were the input documents... I don't need to loop through that array myself.

In the Mapping table Expression, I'm using an Object.filter() method to remove the fields based on a condition - in this case, I only want to keep fields that have some type of value.  In your post, you stated non-null, but show an empty string, which are different in JSON.  So I checked for any value greater than an empty string, which will filter both nulls and empty strings.

Hope this helps!