The following example JSON structure is given:
{
"membership" : [ {
"number" : "1",
"date" : "2023-12-01"
} ],
"addresses" : [ {
"id" : "123",
"company_name" : "xyz",
"salutation" : "mr"
},{
"id" : "456",
"company_name" : "dfg",
"salutation" : "ms"
} ]
}
Using a JSON Transformer Node, I would like to delete all (!) possible fields with “salutation”. The number of list fields is not fixed, so it is possible that “addresses” contains none, one or more elements.
This expression works, but only if addresses contains exactly one element.
[
{ "op": "remove", "path": "/membership" },
{ "op": "remove", "path": "/addresses/0/salutation" }
]
How do I formulate the expression correctly? In any case, this one doesn’t work:
[
{ "op": "remove", "path": "/membership" },
{ "op": "remove", "path": "/addresses/*/salutation" }
]
If I interpret the RFC document correctly, then there are no wildcards and I can only specify absolute paths?
RFC 6902 - JavaScript Object Notation (JSON) Patch (ietf.org)
Should this be the case: How do I reach my goal? Normally I would specify a JSON path as follows, but unfortunately this does not work here…
$.addresses[*].salutation