2
votes

I want to perform some string operation on MEL I have following expression in MEL

<logger message="#[json:xy/PID/xy.3/AC]" level="INFO" doc:name="Logger"/>

OUTPUT IS

19901026000000

I want to extract 1st 4 digit then 6,7 digit .

How can I do this ??

Thanks

3
is this requirement valid for each and every request? i.e first 4 digits and 6th,7th digit everytime?Vihar
yes..need to extractuser3855589

3 Answers

1
votes

What about trying it in two steps?

<set-variable variableName="result" value="#[json:ADT_A01/PID/PID.3/CX.1]" />
<set-variable variableName="result" value="#[result.substring(0,4)]#[result.substring(5,7)]" />
1
votes

As noted in the comments in @Ryan Hoegg answer, the JSON expression evaluator has been deprecated since Mule 3.3 and hence the best way to do this would be to use a json to object transformer

<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.HashMap"/>

and then use conventional MEL to traverse the Map

0
votes

JsonPath expression are depreciated for now and you will even not get enough document on it for doing ..
So, currently you need to use either :- <json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object" />
or <json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object" />
or even <json:json-to-object-transformer returnClass="java.util.List" doc:name="JSON to Object" /> to extract data from JSON depending on the JSON data