Hi Stephane,
I am having an scenario wherein I need to extract a parent value from Json response based on the filter applied on the child value.
Below is the sample response I need to filter the employeeId value based on the filter applied on the child value of severity == NO_SAVE.
$…ruleViolations[?(@.ruleViolationItems.severity=“NO_SAVE”)].employeeId
I have tried the above one but it provides all the employeeId. Could you please help on this.
{
“ruleViolations”: [
{
“ruleType”: “EMPLOYEE”,
“employeeId”: “158916ASFDF”,
“locationPosition”: null,
“ruleViolationItems”: [
{
“date”: “2020-10-02”,
“severity”: “NO_SAVE”,
“message”: “A”
}
]
},
{
“ruleType”: “EMPLOYEE”,
“employeeId”: “1334afdfd”,
“locationPosition”: null,
“ruleViolationItems”: [
{
“date”: “2020-09-28”,
“severity”: “WARNING”,
“message”: “A”
},
{
“date”: “2020-10-02”,
“severity”: “WARNING”,
“message”: “B”
}
]
},
{
“ruleType”: “EMPLOYEE”,
“employeeId”: “1334afdfd”,
“locationPosition”: null,
“ruleViolationItems”: [
{
“date”: “2020-10-02”,
“severity”: “NO_SAVE”,
“message”: “A”
}
]
}
],
“shifts”: []
}