I have an anonymous array of objects and I'd like to find an object by a specific field.
I tried this:
jsonPath.get("$.[?(@.name == 'David')]")
but I'm getting the following error:
Invalid JSON expression:
Script1.groovy: 1: Unexpected input: ' $.[' @ line 1, column 29.
$.[?(@.name == 'David')]
^
1 error
How do I fix that?
The json is:
[
{"name": "David"}, {"name": "Ron"}, {"name": "Dana"}
]
The question is a bit ambiguous, But the syntax is incorrect,
Json path
syntax usesGroovy's GPath
notation