wanglingsong / JsonSurfer

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

relative path after filter #33

Closed gauravphoenix closed 5 years ago

gauravphoenix commented 6 years ago

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;

wanglingsong commented 6 years ago

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

mthaak commented 5 years ago

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.

wanglingsong commented 5 years ago

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.

mthaak commented 5 years ago

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