I have the following json and I'm trying to extract certain elements of the phones array. I don't always get 2 elements, it could be 1,2, or 3.
{
"phones": [{
"id": 123,
"phoneType": "H",
"phoneNumber": "2125551212",
"countryCode": "1",
"isCellPhone": false,
"optInTexting": false
}, {
"id": 456,
"phoneType": "W",
"phoneNumber": "9197776262",
"countryCode": "1",
"isCellPhone": true,
"optInTexting": true
}
]
}
This is what I have with the output:
%output application/java
---
{
HOMEPH: payload.phones filter ($.phoneType == "H") map {HOMEPH:.phoneNumber},
WORKPH: payload.phones filter ($.phoneType == "W") map {WORKPH:$.phoneNumber}
}
The results I get from this:
HOMEPH: [{HOMEPH=2125551212}]
WORKPH: [{WORKPH=9197776262}]
What I want:
HOMEPH: "2125551212",
WORKPH: "9197776262"