我需要在不同的json有效载荷中查找AccountNo字段值。 AccountNo可以存储在json载荷的任何级别。我需要检查AccountNo是否存在,然后在记录器中打印值。寻找JSON hashmap中的特定数据
我正在使用下面的richher,但我想通过mule中的Hashmap迭代来检查AccountNo键是否存在于任何地方,然后获取值。
另请建议,如果有任何其他方式来解析json本身。 在xpath中“// AccountNo”将在整个xml文档中查找AccountNo。我追求类似的东西。
<enricher target="#[flowVars.myJsonMap]" doc:name="Message Enricher"> <json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/> </enricher> <logger message="#[flowVars.myJsonMap.employees[0].AccountNo]" level="INFO" doc:name="Logger"/> </flow>
请看以下例子JSON有效载荷
{
"Account": {
"AccountName": "John",
"AccountNo": "4234324"
}
}
{
"Order": {
"OrderId": "34234242",
"ServiceOrder": [
{
"AccountNo": "231232",
"ServiceOrderId": "54654698787"
},
{
"AccountNo": "231232",
"ServiceOrderId": "78979879797"
}
]
}
在这种情况下,我不知道我的密钥将嵌套在哪里。请在我的原始评论中找到上面的示例负载。 – user3366906