Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mule getting data from json payload

Tags:

groovy

xpath

mule

My payload is

<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 json array input given)

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

Now, I need to get data from the payload:

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

it prints null. How do I get data from the payload using MEL? Is there any simpler way of getting in Groovy or xpath?

EDIT

Passed single json data as:

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

logger:

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

it prints null value.

like image 550
TechFind Avatar asked Nov 30 '22 01:11

TechFind


1 Answers

In Mule ESB 3.7.0

This work:

#[json:Name]
like image 148
Daniel De León Avatar answered Dec 05 '22 00:12

Daniel De León