Mule gets data from json payload

My payload

<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>`

which prints (this is the given input of the json array)

[{"Name": "My Name", "Address": "add1", "Location": "NY"}]

Now I need to get the data from the payload:

<logger message="#[payload.Name]" level="INFO" doc:name="Logger"/>

it prints zero. How to get data from a payload using MEL? Is there an easier way to access Groovy or xpath?

EDIT

Passed single json data as:

{"Name":"My name","Address":"add1","Location":"NY"}

Registrar:

  <logger message="#[payload.Name]" level="INFO" doc:name="Logger"/>

it prints a null value.

+4
source share
2 answers

UPDATE. Mule JSON Path MEL, #[json:Name] .

MEL

MEL JSON. json-to-object JSON , MEL.

, :

<json:json-to-object-transformer returnClass="java.lang.Object" />
<logger message="#[message.payload[0].Name]" level="INFO" />

[0], :

[{"Name":"My name","Address":"add1","Location":"NY"}]

JSON, JSON, JSON.

+7

Mule ESB 3.7.0

:

#[json:Name]
+11

All Articles