christwr
8 years agoContributor III
JSON Query - Workday =/
I have JSON data from Workday with potentially many Phone_Data sections like below:
"Phone_Data" : [
{
"Formatted_Phone" : "XXXXXXXX",
"Phone_Device_Type_Reference" : {
"ID" : {
"Phone_Device_Type_ID" : "Telephone"
}
},
"Usage_Data" : [
{
"Public" : "1",
"Type_Data" : [
{
"Primary" : "1",
"Type_Reference" : {
"ID" : {
"Communication_Usage_Type_ID" : "WORK"
}
}
}
]
}
]
}
]
I have it getting the “first” WORK Formatted_Phone with code like below:
jsonPath($, "$Worker_Data.Personal_Data.Contact_Data.Phone_Data[?(value.Usage_Data[0].Type_Data[0].Type_Reference.ID.Communication_Usage_Type_ID == 'WORK')].Formatted_Phone")[0]
But I want the one where Primary==1 too…
I’ve played around a bit trying to put more conditions in there, but always end up with various errors. I’m pretty good with this kind of thing using XPATH with XML, but this is eluding me with JSON.
Any help is much appreciated!