我有一个JDBC COnnector,它从数据库中检索值,并将它们从对象映射到JSON。 现在我想从json中提取特定值到流变量。 当我尝试记录#[message.payload]时,我在日志中获得了JSON格式的完整有效负载。 但是当我尝试选择一个属性(例如json中的testattribute)#[message.payload.testattribute]时,我得到mule表达式错误。 我如何参考json值?
I have a JDBC COnnector which retrieves values from the database and I have mapped them from object to JSON. Now I want to extract specific values from the json to flow variables. When I try to log #[message.payload], I get the full payload in the log which is in JSON format. However when I try to choose an attribute (eg. testattribute in json) #[message.payload.testattribute], I get mule expression error. How do I refer to the json values?
最满意答案
一旦有效负载是JSON字符串,您就不能再使用表达式从中提取任何内容。
所以要么:
在将有效负载转换为JSON之前,使用MEL将值提取到流变量中, 将JSON有效负载转换为POJO或Map / Lists,使用MEL将值提取到流变量中,并将有效负载重新转换回JSON。Once the payload is a JSON string, you can't extract anything from it anymore with an expression.
So either:
use MEL to extract the values into flow variables prior to convert the payload into JSON, transform the JSON payload to either POJOs or Map/Lists, use MEL to extract the values into flow variables, and re-transform the payload back to JSON.更多推荐
发布评论