Forum Discussion
You can do use a JOIN Snap and get the desired o/p.
There is no hard and fast rule on when to use an Expression Language or Snap. It will mostly depend on your ease of writing an Expression.
Thank you so much. It worked by creating an empty $array[*].subArray. Do you know where I can learn more about the syntax to use to manipulate JSON like this? I get stuck and spin my wheels a lot on these types of issues.
Also, is there a way to delete just a simple field, not an array/list, with the Mapper if its null like the above expression did for the array? When the right Target path is empty, I’m not sure what expression to use on the left to return the field when its null.
We have our own documentation for JSON-Path. There are also online testers, like:
Note that most JSON-Path implementations are only for reading data, whereas we use it for updating and deletions. So,
In the Designer, you should be able to drill down into the document structure in the Mapper and in the drop-down for expression properties.
It’s pretty much the same thing, except instead of checking for
value.field1 == null
you can check ifvalue == null
. So, you would write a path to the object whose fields you want to delete (e.g.$.foo.bar
) and then use the filter operator ([?(... expr ...)]
) to select the fields to delete:$.foo.bar[?(value == null)]
If I have the following in a JSON Generator and a subsequent Mapper, what do I put in the Expression to remove “id” field if its null? I’m getting a parsing error when trying $.id[?(value == null)].
[
{
“id”: 21,
“eId”: [
256,
2,
548,
14010
]
},
{
“id”: null,
“eId”: [
256,
2,
548,
14010
]
}
]
Related Content
- 2 years ago
- 4 years ago
- 3 years ago