I need to look for AccountNo field value in different json payloads. AccountNo can exist at any level in json payload. I need to check if AccountNo exists and then print value in logger.
I am using below enricher but I want to iterate through the Hashmap in mule to check if AccountNo key exists anywhere and then get the value.
Also please suggest if any other way to parse json itself. In xpath "//AccountNo" will look for AccountNo in whole xml document. I am after something similar.
<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>
Please find below example json payloads
{
"Account": {
"AccountName": "John",
"AccountNo": "4234324"
}
}
{
"Order": {
"OrderId": "34234242",
"ServiceOrder": [
{
"AccountNo": "231232",
"ServiceOrderId": "54654698787"
},
{
"AccountNo": "231232",
"ServiceOrderId": "78979879797"
}
]
}