RFC6901 JSON Pointer implementation in OCaml using jsont
1# Valid JSON Pointer parsing tests
2# Format: pointer -> indices (Mem:name, Nth:n, End)
3
4# Root pointer (empty string)
5 -> []
6
7# RFC 6901 Section 5 examples
8/foo -> [Mem:foo]
9/foo/0 -> [Mem:foo, Nth:0]
10/ -> [Mem:]
11/a~1b -> [Mem:a/b]
12/c%d -> [Mem:c%d]
13/e^f -> [Mem:e^f]
14/g|h -> [Mem:g|h]
15/i\j -> [Mem:i\j]
16/k"l -> [Mem:k"l]
17/ -> [Mem: ]
18/m~0n -> [Mem:m~n]
19
20# Array indices
21/0 -> [Nth:0]
22/1 -> [Nth:1]
23/10 -> [Nth:10]
24/123 -> [Nth:123]
25/999999 -> [Nth:999999]
26
27# End-of-array marker
28/- -> [End]
29/foo/- -> [Mem:foo, End]
30/arr/0/- -> [Mem:arr, Nth:0, End]
31
32# Multiple levels
33/a/b/c -> [Mem:a, Mem:b, Mem:c]
34/0/1/2 -> [Nth:0, Nth:1, Nth:2]
35/foo/0/bar/1 -> [Mem:foo, Nth:0, Mem:bar, Nth:1]
36
37# Escape sequences
38/~0 -> [Mem:~]
39/~1 -> [Mem:/]
40/~0~1 -> [Mem:~/]
41/~1~0 -> [Mem:/~]
42/~01 -> [Mem:~1]
43/a~0b~1c -> [Mem:a~b/c]
44
45# Empty member names
46// -> [Mem:, Mem:]
47/// -> [Mem:, Mem:, Mem:]
48/foo//bar -> [Mem:foo, Mem:, Mem:bar]
49
50# Special characters (not needing escaping)
51/hello world -> [Mem:hello world]
52/with spaces -> [Mem:with spaces]
53/unicode-\u00e9 -> [Mem:unicode-\u00e9]