How to access json mule esb data

I want to access json data generated from a synchronization stream into an async stream. I get json data from the synchronization stream correctly, and I want to get a specific attribute value from the fact that my json data looks like this:

{"data" : [{"in_timestamp":"2012-12-04","message":"hello","out_timestamp":null,"from_user":"user2","ID":43,"to_user":"user1"}]} and to user is #[json:to_user]} 

I want to access the to_user attribute from this json format. I tried using #[json:to_user] , but it just prints it as a string and returns no value. Please help. Thanks in advance.

+4
source share
2 answers

The correct expression based on your JSON example:

 #[json:data[0]/to_user] 
+16
source

The JsonPath expression is currently depreciating, and you won't even get enough document to execute it.
So, for now, 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 retrieve data from JSON depending on JSON data.

+3
source

All Articles