jaxon icon indicating copy to clipboard operation
jaxon copied to clipboard

Towards a shared understanding of JSONPath

Open cburgmer opened this issue 5 years ago • 1 comments

You might find https://cburgmer.github.io/json-path-comparison/ interesting to align with other implementations of JSONPath. To give an idea what's possible here are two queries which are currently not supported by jaxon/return the wrong results.

  • [ ] $[-1] Input:

    ["first", "second", "third"]
    

    Expected output:

    ["third"]
    

    Actual output:

    []
    
  • [ ] $..key Input:

    {"object": {"key": "value", "array": [{"key": "something"}, {"key": {"key": "russian dolls"}}]}, "key": "top"}
    

    Expected output:

    ["russian dolls", "something", "top", "value", {"key": "russian dolls"}]
    

    Actual output:

    ["top"]
    

Let me know if this is helpful to you.

For reference, the output was generated by the program in https://github.com/cburgmer/json-path-comparison/tree/master/implementations/Elixir_jaxon.

cburgmer avatar Jan 03 '20 22:01 cburgmer

Thank you for the library.

Hi @cburgmer

I am wondering how to slice the json?

I tried Jaxon.Stream.query(Jaxon.Path.parse!("$[0:3].Player")) to get first 3 players I have, but it does not work.

How can I use it correctly to get only partial data and filters?

Should I use Enum.take?

tiagodavi avatar Mar 03 '20 02:03 tiagodavi