I am trying to check the given input string is present in a json array. Below is my sample json
{
"school": {
"class": {
"standard": "6",
"student_list": [
"Daniel",
"Jack",
"John"
]
}
}
}
Let say i am trying to find a given input name is part of student_list if the given input name matches then it should retrieve the complete details of the class. Let say i am passing name 'John' it should give me below result
{
"standard": "6",
"student_list": [
"daniel",
"jack",
"john"
]
}
I am using jayway json path library i tried couple of ways like below
$.school.class.[?('john' anyof @.student_list)]
$.school.class.[?(@.'john' anyof @.student_list)]
But every time it is giving me empty array. I am new to jsonpath query could you please point me where i am going wrong or help me what is wrong with my json path query.