Skip to content

Results do not match other implementations #35

@cburgmer

Description

@cburgmer

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

  • $.2
    Input:

    {"a": "first", "2": "second", "b": "third"}
    

    Expected output:

    ["second"]
    

    Error:

    line 1:2 mismatched input '2' expecting {'*', ID}
    ValueError("line 1:2 mismatched input '2' expecting {'*', ID}")
    
  • $[::2]
    Input:

    ["first", "second", "third", "forth", "fifth"]
    

    Expected output:

    ["first", "third", "fifth"]
    

    Actual output:

    ["first", "second"]
    
  • $[?(@.key==42)]
    Input:

    [{"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"some": "value"}]
    

    Expected output:

    [{"key": 42}]
    

    Error:

    line 1:10 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
    ValueError("line 1:10 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}")
    
  • $[?(@.key>42)]
    Input:

    [{"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}]
    

    Expected output:

    [{"key": 43}, {"key": 42.0001}, {"key": 100}]
    

    Actual output:

    []
    
  • $[?(@.key)]
    Input:

    [{"some": "some value"}, {"key": "value"}]
    

    Expected output:

    [{"key": "value"}]
    

    Actual output:

    []
    
  • $['key']
    Input:

    {"key": "value"}
    

    Expected output:

    ["value"]
    

    Error:

    line 1:2 token recognition error at: '''
    ValueError("line 1:2 token recognition error at: '''")
    

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions