Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results do not match other implementations #115

Closed
5 tasks
cburgmer opened this issue Jun 16, 2019 · 5 comments
Closed
5 tasks

Results do not match other implementations #115

cburgmer opened this issue Jun 16, 2019 · 5 comments

Comments

@cburgmer
Copy link

The following queries provide results that do not match those of other implementations of JSONPath
(compare https://github.com/cburgmer/json-path-comparison/tree/master/comparison):

  • $[1:10]
    Input:

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

    Expected output:

    ["second", "third"]
    

    Actual output:

    []
    
  • $['0']
    Input:

    {"0": "value"}
    

    Expected output:

    "value"
    

    Actual output:

    null
    
  • $..*
    Input:

    {"another key": {"primitives": [0, 1], "complex": "string"}, "key": "value"}
    

    Expected output:

    ["value", {"primitives": [0, 1], "complex": "string"}, "string", [0, 1], 0, 1]
    

    Actual output:

    [{"another key": {"primitives": [0, 1], "complex": "string"}, "key": "value"}, "value", {"primitives": [0, 1], "complex": "string"}, "string", [0, 1], 0, 1]
    
  • $.*
    Input:

    ["string", 42, {"key": "value"}, [0, 1]]
    

    Expected output:

    ["string", 42, {"key": "value"}, [0, 1]]
    

    Actual output:

    [["string", 42, {"key": "value"}, [0, 1]]]
    
  • $.*
    Input:

    {"int": 42, "array": [0, 1], "object": {"key": "value"}, "some": "string"}
    

    Expected output:

    ["string", 42, {"key": "value"}, [0, 1]]
    

    Actual output:

    [{"int": 42, "array": [0, 1], "object": {"key": "value"}, "some": "string"}]
    

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

@Skarlso
Copy link
Collaborator

Skarlso commented Jun 18, 2019

Interesting. I'll take a look. Some of these are definitely weird.

@Skarlso
Copy link
Collaborator

Skarlso commented Jun 18, 2019

One thing though. This: $['0'] is not supported, yeah. :)

@Skarlso
Copy link
Collaborator

Skarlso commented Jun 20, 2019

So. We are also returning the keys basically, not just the values in case of $..*. I think that is fine. The people who are using this library came to expect that for a long time now, so I'm not going to change the implementation to match that of others.

That would break the current usage pattern of this gem which people using it rely upon. If people would like to have other types of results, I suggest to use a different gem. I don't see this a bug. :) It's a feature of this gem to also include the keys in the results. If you happen to find an inconsistency which shows up as a bug, please report that separately. Thank you!

@Skarlso Skarlso closed this as completed Jun 20, 2019
@cburgmer
Copy link
Author

Thanks for your response.
Part of this issue was to gather feedback on whether this kind of qualitative comparison is helpful to the projects. I would post issues for further items that come up via this mechanism if helpful.

@Skarlso
Copy link
Collaborator

Skarlso commented Jun 21, 2019

Absolutely please do so. And thank you for the issue and your time. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants