06-14-2017 07:37 AM
I have a json file with an array designed like below. I don’t have control over the number of or order of address entries. I have tried $.Address.findIndex(x => x == ‘Home’) and $.Address ? (value.AddrType = Home) among other expression language statements.
I would like to query the array by AddrType and get the index of the matching array entry record. Has anyone done something similar. We are attempting to normalize<<>>denormalize records based on types to denormalized fields that correspond to the types.
{fnam:“Joe”,Lname:“Long”,
Address:[
{
“AddrType”: “Mailing”,
“StreetAddr1”: “123 Prospect Street”,
“City”: “Waltham”,
“State”: “MA”,
“Zipcode”: “”
},
{
“AddrType”: “Main”,
“StreetAddr1”: “123 Baystate Street”,
“City”: “”,
“State”: “”,
“Zipcode”: “”,
}
]
06-14-2017 08:11 AM
Is this the exact expression that you tried?
If so, it won’t work because you missed the ‘AddrType’ field reference. Something like this should work:
$.Address.findIndex(x => x.AddrType == "Home")
06-14-2017 10:38 AM
Works perfectly thank you.