Mule如何将Json值从有效负载映射到流变量(Mule how to map Json values from payload to flow variables)

编程入门 行业动态 更新时间:2024-10-28 05:16:13
Mule如何将Json值从有效负载映射到流变量(Mule how to map Json values from payload to flow variables)

我有一个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.

更多推荐

本文发布于:2023-07-17 07:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:负载   如何将   Json   Mule   map

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!