wanglingsong / JsonSurfer

A streaming JsonPath processor in Java
MIT License
292 stars 55 forks source link

Get attribute value with filtering not working #41

Closed trungsi closed 6 years ago

trungsi commented 6 years ago

Hello

I have a json structure like this { "policy" : { "policy-details" : { "parties" : { "party" : [{"role" : "role1", "name" : "name1"}, {"role" : "role2", "name" : "name2"}]}} } } With this jsonPath $.policy.policy-details.parties.party[?(@.role == 'role1')].name I got org.antlr.v4.runtime.misc.ParseCancellationException at org.antlr.v4.runtime.BailErrorStrategy.recoverInline(BailErrorStrategy.java:66) at org.antlr.v4.runtime.Parser.match(Parser.java:206) at org.jsfr.json.compiler.JsonPathParser.path(JsonPathParser.java:154) at org.jsfr.json.compiler.JsonPathCompiler.compile(JsonPathCompiler.java:238) at org.jsfr.json.SurfingConfiguration$Builder.bind(SurfingConfiguration.java:148)

But the path is working while testing on http://jsonpath.com/.

Is it a bug or not supported ?

Thanks

wanglingsong commented 6 years ago

There is a limitation. No more path after the filter clause. The working path has to be:


$.policy.policy-details.parties.party[?(@.role == 'role1')]
wanglingsong commented 6 years ago

README updated

trungsi commented 6 years ago

Thanks.

Any plan to provide full support for jsonpath ?

wanglingsong commented 6 years ago

No plan yet. However, any contribution are welcomed.