Skip to content

Instantly share code, notes, and snippets.

@geraintluff
Last active March 25, 2023 07:14
Show Gist options
  • Save geraintluff/5911303 to your computer and use it in GitHub Desktop.
Save geraintluff/5911303 to your computer and use it in GitHub Desktop.
Additional Relative JSON Pointer examples
{
"test": ["foo", "bar"],
"child": {
"grandchild": 12345
},
"sibling": "sibling value",
"awkwardly/named~variable": true
}
Starting value Relative JSON Pointer result
-------------------------------------------------------------------------
"bar" "0" "bar"
"bar" "0#" 1
"bar" "1" ["foo", "bar"]
"bar" "1/0" "foo"
"bar" "1/1" "bar"
"bar" "1#" "test"
"bar" "2" << the whole document >>
"bar" "2#" << fails >>
"bar" "3" << fails >>
12345 "0" 12345
12345 "0#" "grandchild"
12345 "1" {"grandchild": 12345}
12345 "1/grandchild" 12345
12345 "1#" "child"
12345 "2" << the whole document >>
12345 "2/sibling" "sibling value"
12345 "2/test/1" "bar"
{"grandchild": 12345} "0" {"grandchild": 12345}
{"grandchild": 12345} "0#" "child"
{"grandchild": 12345} "0/grandchild" 12345
{"grandchild": 12345} "1/sibling" "sibling value"
{"grandchild": 12345} "2" << the whole document >>
"sibling value" "0" "sibling value"
"sibling value" "0#" "sibling"
"sibling value" "1" << the whole document >>
"sibling value" "1/awkwardly~1named~0variable" true
true "0" true
true "0#" "awkwardly/named-variable"
@yww325
Copy link

yww325 commented Jul 23, 2020

how to use the Relative JSON Pointer in a schema actually? Do I need to use $data or $ref?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment