Forum Discussion
Hello ptaylor,
Yes I agree, and I managed to make it look like a real JSON (and finally converting it successfully) using a few string replacements, including some regex.
It looks not really clean to me, and I was hoping to fix the format in a simpler way. But it works now, I guess that's the most important... 🙂
Thanks a lot for your reply, have a good rest of your day!
JF
Great! Good that you have control over the source of the string.
Hi @acesario,
There is an expression. You can remove all field that are null or only by specific fields.
For this you must use Mapper and you need to have checked Pass Through checkbox and also target path need to be empty.$group...[?(value == null && key == "fieldName")]
$group: Is an array and if you remove the “group” and let stay only “$” then it will work again but it will check through whole document.
value: We specify what value we want to remove. In this situation is null.
key: If we have to specify name of field that we want to remove, then we set key in the conditions. If we only need to check by value then remove the key. Ex:
$group...[?(value == null)]
Regards,
Viktor Nedanovski@matt.bostrom, use a Mapper, with Pass-Through enabled and with the field you wish to exclude/delete mapped to an empty Target Path:
- matt_bostrom8 years agoNew 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.
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):
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_bostrom8 years agoNew Contributor II
Got it. That worked for me! Thank you both for the help.
- suehocking8 years agoNew Contributor
this isnt working for me!!
Could not compile expression: $group[].matchfield (Reason: Encountered extraneous input ‘[’ at line 1:6; expecting={, ‘||’, ‘&&’, ‘^’, ‘==’, ‘!=’, ‘>’, ‘<’, ‘>=’, ‘<=’, ‘+’, ‘-’, '', ‘/’, ‘%’, ‘?’, ‘instanceof’, ‘in’, ‘.’}; Resolution: Please check expression syntax)Make sure the “Target Path” column in the mapper is cleared. Otherwise, the mapper will treat the first column as an expression, which is what it looks like is happening here. (When the Target Path is clear, the first column is treated as a JSON-Path that specifies what should be deleted in the input document).
Related Content
- 11 months ago
- 2 years ago
- 2 years ago
- 2 years ago