freestrings / jsonpath

JsonPath engine written in Rust. Webassembly and Javascript support too
MIT License
122 stars 37 forks source link

why select always returns a vector? How to use this for single return value? #45

Open coding-yogi opened 4 years ago

coding-yogi commented 4 years ago

All examples for this library are around vectors. Not a single example shows how to fetch just a specific value from json using jsonpath. If select returns vector everytime, how would program know if returned value was actually an json array or json value?

Also there is incosistency in the results returned by select and select_as_str

I have below json. For json path $.args.foo1, select_as_str() returns "[\"bar1\"]" which is ofcourse wrong and select() doesn't return anything!! but empty array

{
    "args": {
        "foo1": "bar1",
        "foo2": "bar2"
    }
}