wanglingsong / JsonSurfer

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

Collector interface enhancement #58

Closed wanglingsong closed 4 years ago

wanglingsong commented 5 years ago

Currently, the "collect" interfaces are not handy, because It surfs the whole json and apply only one JsonPath for each collection which is obviously not efficient at all. So I plan to add following interface:

    JsonSurfer surfer = JsonSurferJackson.INSTANCE;
    Builder builder = surfer.configBuilder();
    Holder holder1 = builder.collectOne("$.store");
    Holder holder2 = builder.collectAll("$.store.book[*]");
    builder.buildAndSurfer(json);
    holder1.get();
    holder2.get();

The enhanced interface will allow user to add any desired JsonPath during config building phase and collect everything matched into holders within a single surfing.