we have array of objects which we are storing in RedisJson. object looks like this
[
{
"abcd": null,
"pqrs": "002090618000132",
"xyz":"SomeValue2",
"mnop": 5,
"Properties": {
"property1": "04240424",
"property2": "04240424",
"property3": "04240424"
},
"Alarms": {}
},
{
"abcd": null,
"pqrs": "002090618000132",
"xyz":"SomeValue3",
"mnop": 5,
"Properties": {
"property1": "04240424",
"property2": "04240424",
"property3": "04240424"
},
"Alarms": {}
}
]
I need to find out all elements in given array where xyz==SomeValue2. I tried multiple things, however, did not worked for me.
Query I am trying to filter the above data is
json.get SomeKey $[?(xyz==SomeValue2)]
Also tried
json.get SomeKey $.[?(xyz==SomeValue2)]
also
json.get SomeKey $[?(@.xyz==SomeValue2)]
everytime I am getting below error
"JSON Path error: path error: \n$[?(xyz==SomeValue2)]\n^^^^^^^^^^^^^^\n"
Somehow I am not able to get to the exact tree structure what redis is following
When I tried to get data without filter I am getting it
json.get SomeKey $[0]
json.get SomeKey $[0].xyz
Please suggest what I am missing.
Quote the entire path, and quote the string value
JSON.GET SomeKey '$[?(@.xyz=="SomeValue2")]'