Closed moshevi closed 5 years ago
But currently it's not supported out of the box as jsonpath expression?
You can use it via: `builder := gval.Full(jsonpath.Language())
path, err := builder.NewEvaluable("$..[?@ =~ \"[fF][oO]+\"]")`
RegEx is not part of the JSonPath specification so I'm not planning to add it into jsonpath.Language()
Thanks generikvault for your answers
@generikvault Just another filter question: Can I filter an object attribute value or just an array one. For example I have this JSON: {"a":1, "b":2} How can I get a yes/no one-liner JsonPath expression that will return true for a==1 and false for a==2 ?
What do you want to achieve?
$.a == 1
returns true or false as descibed.
If you want to filter for a specific Object let's say in {"x":{"a":1, "b":2},"y":{"a":2, "b":3}}
you can do this with $[@.a == 1]
Thanks @generikvault
Merge jsonpath with gval.Text() or gval.Full() for Regex support. For latter is in example in the godoc.
You find regex operators in the godoc of gval.Text(): https://godoc.org/github.com/PaesslerAG/gval#Text