Skip to content

Alignment with spec in its current state (a report) #127

Open
@gregsdennis

Description

@gregsdennis

I've recently updated my implementation (JsonPath.Net) to conform with the spec. I haven't published it yet, but I wanted to share a finding.

These tests are not in alignment with the spec. I realize that spec alignment isn't a goal of this project, but I wanted to share my results.

// dashes are not allowed in shorthand property names
// discussion: https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/16
$.key-dash
$[?(@.key-dash == 'value')]

// shorthand property names must start with a letter
$.2",
$[?(@.2 == 'second')]
$[?(@.2 == 'third')]
$.-1
$.$
$.'key'
$."key"
$.."key"
$..'key'
$..'key'
$.'some.key'

// leading zeroes are not allowed for numeric literals
// reason: disallowed for JSON, so copied here
$[?(@.key==010)]
$[010:024:010]

// JSON literals are not expression results
$[?(@.key>0 && false)]
$[?(@.key>0 && true)]
$[?(@.key>0 || false)]
$[?(@.key>0 || true)]
$[?((@.key<44)==false)]
$[?(true)]
$[?(false)]
$[?(null)]

// leading and trailing whitespace is disallowed
// https://github.com/jsonpath-standard/jsonpath-compliance-test-suite/issues/13
"$. a "

// regex operator transitioned to functions
// discussion: https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/70
// discussion: https://github.com/ietf-wg-jsonpath/iregexp/issues/15
$[?(@.name=~/hello.*/)]
$[?(@.name=~/@.pattern/)]

// functions are only valid in expressions and are not extensions on paths
// discussion (length): https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/154
// discussion (functions): https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/203 
$.data.sum()
$[?(@.length() == 4)]

// relative paths were excluded
// discussion: https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/59
@.a

// 'in' operator was excluded
// discussion: https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/64
$[?(@.d in [2, 3])]
$[?(2 in @.d)]

// only JSON primitives are supported in expressions
$[?(@.d==['v1','v2'])]

// only singular paths are allowed in comparisons
$[?(@[0:1]==[1])]  // also array literals are disallowed
$[?(@.*==[1,2])]   // also array literals are disallowed
$[?(@[0:1]==1)]
$[?(@[*]==2)]
$[?(@.*==2)]
$[?(@[*]>=4)]
$.x[?(@[*]>=$.y[*])]

// other invalid syntaxes
$...key
$.['key']
$.[\"key\"]
$..
$.key..
.key
key
      // empty string
$[?(@.key===42)]

// big numbers not supported
$[2:-113667776004:-1]
$[113667776004:2:-1]

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