wanglingsong/JsonSurfer

relative path after filter

Closed this issue · 4 comments

I am trying JSON path $.store.book[?(@.price < 10 || @.category =='fiction')].author but getting an error Caused by: org.antlr.v4.runtime.InputMismatchException

is this due to the assumption that after a filter, there may not be a relative path? the antlr grammar file JsonPath.g4 currently has- path: '$' relativePath* filter? EOF;

no, there should not be anything after filter as the antlr grammar definition.

Is this a design choice? Because I think this is a really significant deficiency.
Would it take much work to change the ANTLR grammar definition? If not I may consider to do it myself.

Yes. Currently, Our JsonFilter applys only to the leaf nodes of a JSON object. It's not a problem with ANTLR grammar. Due to the streaming architecture of JsonSurfer there are difficulties to implement such "general" filter you wish. At least I haven't found perfect plan for it. Howerver, any contirbutions are welcomed, if you got any good idea.

We are using this library for one of our company's products. This feature would make a good addition. I might look into it further when I have the time. Thanks