Skip to content

Instantly share code, notes, and snippets.

@handrews
Created February 18, 2023 18:20
Show Gist options
  • Save handrews/41b3b7cd6c011563f6a39b766b09c4c7 to your computer and use it in GitHub Desktop.
Save handrews/41b3b7cd6c011563f6a39b766b09c4c7 to your computer and use it in GitHub Desktop.
Syntax error test cases for JSON Pointer (JP) and Relative JSON Pointer (RJP)
Malformed ptr Notes
=====================
"0" valid RJP
"1-4#" valid RJP
"0+20/foo/bar valid RJP
"foo/bar" missing initial "/"
"/foo~/bar" unescaped "~"
Note that several of these catch likely regular expression errors,
such as improper grouping of terms or incorrectly handling 0.
Malformed rel ptr Notes
=========================
"/foo/bar" valid JP
"0+" missing index adjusmtent number
"-2/foo/bar" missing parent adjustment
"0+0" 0 index adjusmtent not allowed (0 plus)
"0-0" 0 index adjustment not allowed (0 minus)
"1+0/foo" 0 index adjustment not allowed (non-0 plus)
"4-0#" 0 index adjustment not allowed (non-0 minus)
"0+A" non-numeric index adjustment
"*+1#" non-numeric parent adjustment
"2foo/bar" missing leading "/" for pointer
"1#/foo/bar" index name and pointer together
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment