wanglingsong / JsonSurfer

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

JsonSurfer cannot parse boolean attributes #46

Closed adamsiemion closed 5 years ago

adamsiemion commented 5 years ago

Given the following JSON

[{"a": true, "b": 1}, {"a": false, "b": 2}, {"a": false, "b": 3}]

and code

JsonSurferJackson.INSTANCE.collectAll(inputStream, "$[?(@.a==false)]")

JsonSurfer fails with

line 1:9 no viable alternative at input '@.a==false'

org.antlr.v4.runtime.misc.ParseCancellationException
    at org.antlr.v4.runtime.BailErrorStrategy.recover(BailErrorStrategy.java:51)
    ...
Caused by: org.antlr.v4.runtime.NoViableAltException
wanglingsong commented 5 years ago

Sorry, JsonSurfer currently supports only number and quoted string in the filter clause. I will try to implement it in the next release.

adamsiemion commented 5 years ago

@wanglingsong thank you very much for the reply, any estimates when v1.4.4 can be released? i could really benefit from this feature.

wanglingsong commented 5 years ago

Hi, @adamsiemion I just implemented boolean comparison filter in the latest commit. You can try it by cloning from the source before official 1.4.4 release. BTW, I think your JsonPath was wrong, you should use "$[*][?(@.a==false)]" instead.

adamsiemion commented 5 years ago

@wanglingsong great stuff, thank you very much!