Accessing content from JSON payloads using wso2 ESB
If you have come up with the requirement of accessing JSON content from JSON payload within the mediation flow of the Wso2 ESB, You should send the “Content-Type” HTTP header with the request like below.
“Content-Type : application/json”
Then with in the mediation flow of the ESB (within proxy service,sequence,REST API), you can access the JSON payload using JSONPath syntax. See the following example. JSON payload like below
If you want to access the “name” field of the first “location” member of the above JSON payload,
You can achieve that using following JSONPath expression.
<property name=”location” expression=”json-eval($.coordinates.location.name)”></property>
If you send a request like following
You can see below log line in the Wso2Carbon logs.
INFO - LogMediator To: /def, MessageID: urn:uuid:89c8074e-e03f-4e0f-9dc7-c01bc2c3c30c, Direction: request, location = Bermuda Triangle
You can refer document , for get more idea about the JSON payload handling in the Wso2 ESB and get an idea about the JSONPath syntax.