how to access json data mule esb

空扰寡人 提交于 2019-11-29 15:18:22

问题


i want to access json data generated from the sync flow into an async flow. I am getting json data from sync flow correctly and i want to fetch certain attribute value from that my json data is as follows :

{"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 to_user attribute from this json format. I have tried using #[json:to_user] but it simply prints it as a string and doesnt return any value. Please help. Thanks in advance.


回答1:


The right expression based on your sample JSON is:

#[json:data[0]/to_user]



回答2:


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



来源:https://stackoverflow.com/questions/13703573/how-to-access-json-data-mule-esb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!