I have a JSON Object that looks like this:
{"firstName":"Todd","lastName":"Jones","age":32}
My question is how can I remove the age field? I was looking in the Enrich Mediator documentation and noticed an example to remove selected parts from a payload:
Sample 7 - Remove selected parts from the payload ( this feature is available from EI 6.6.0 WUM level 1595516738094 )
<target>
<inSequence>
<enrich>
<source clone="true" xpath="json-eval($.store.book[*].author,$.store.book[0])"/>
<target type="body" action="remove"/>
</enrich>
<respond/>
</inSequence>
<outSequence/>
</target>
This would not work for me however because it is available on EI 6.6.0 and I am on EI 6.1.1. How else could I go about achieving the intended result?
If your payload is only 3 elements I reckon you could just go with the payloadfactory.
You might have to enable the JSON stream formatter/builder for this as described here. https://docs.wso2.com/display/EI611/PayloadFactory+Mediator
If the above doesn't work you could also first put the firstName and lastName into separate properties and then reference it as a context property.
I.e.
<arg evaluator="xml" expression="$ctx:firstName"/>