I have this JSON :
[
{
"id": "1",
"agent": "23ef",
"displayName": "foo.com"
},
{
"id": "2",
"agent": "23gh",
"displayName": "foo2.com"
},
{
"id": "3",
"agent": "23gf",
"displayName": "boo.com"
}
]
Wanted to get the dataset for all objects which have foo in their displayName.
I am able to get when i pass the value as a string,
$ cat /tmp/z.json | jq -r '.[] | select(.displayName=="foo.com")' { "id": "1", "agent": "23ef", "displayName": "foo.com" }
But not getting when i try a regex. Can somebody help?
$ cat /tmp/z.json | jq -r '.[] | select(.displayName=="foo*")'
2
use this
cat /tmp/z.json | jq -r ‘.[] | select(.displayName | test(“^foo”))’
== operator does not supported in regex pattern
hope this work for you !!
1