Skip to content

Results do not match other implementations #60

@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:

    Exception in thread "main" org.antlr.v4.runtime.misc.ParseCancellationException
    	at org.antlr.v4.runtime.BailErrorStrategy.recoverInline(BailErrorStrategy.java:66)
    	at org.antlr.v4.runtime.Parser.match(Parser.java:206)
    	at org.jsfr.json.compiler.JsonPathParser.childNode(JsonPathParser.java:672)
    	at org.jsfr.json.compiler.JsonPathParser.relativePath(JsonPathParser.java:272)
    	at org.jsfr.json.compiler.JsonPathParser.path(JsonPathParser.java:159)
    	at org.jsfr.json.compiler.JsonPathCompiler.compile(JsonPathCompiler.java:283)
    	at org.jsfr.json.compiler.JsonPathCompiler.compile(JsonPathCompiler.java:273)
    	at org.jsfr.json.JsonSurfer.collectAll(JsonSurfer.java:262)
    	at query.App.main(App.java:27)
    Caused by: org.antlr.v4.runtime.InputMismatchException
    	at org.antlr.v4.runtime.BailErrorStrategy.recoverInline(BailErrorStrategy.java:61)
    	... 8 more
    
  • $[-1]
    Input:

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

    Expected output:

    ["third"]
    

    Actual output:

    []
    
  • $[-1:]
    Input:

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

    Expected output:

    ["third"]
    

    Actual output:

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

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

    Expected output:

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

    Error:

    line 1:11 token recognition error at: '"'
    line 1:22 token recognition error at: '"'
    line 1:12 no viable alternative at input '@.key==some'
    Exception in thread "main" org.antlr.v4.runtime.misc.ParseCancellationException
    	at org.antlr.v4.runtime.BailErrorStrategy.recover(BailErrorStrategy.java:51)
    	at org.jsfr.json.compiler.JsonPathParser.filterExpr(JsonPathParser.java:947)
    	at org.jsfr.json.compiler.JsonPathParser.filter(JsonPathParser.java:768)
    	at org.jsfr.json.compiler.JsonPathParser.relativePath(JsonPathParser.java:307)
    	at org.jsfr.json.compiler.JsonPathParser.path(JsonPathParser.java:159)
    	at org.jsfr.json.compiler.JsonPathCompiler.compile(JsonPathCompiler.java:283)
    	at org.jsfr.json.compiler.JsonPathCompiler.compile(JsonPathCompiler.java:273)
    	at org.jsfr.json.JsonSurfer.collectAll(JsonSurfer.java:262)
    	at query.App.main(App.java:27)
    Caused by: org.antlr.v4.runtime.NoViableAltException
    	at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
    	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
    	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
    	at org.jsfr.json.compiler.JsonPathParser.filterExpr(JsonPathParser.java:843)
    	... 7 more
    

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions