tangled
alpha
login
or
join now
anil.recoil.org
/
ocaml-json-pointer
0
fork
atom
RFC6901 JSON Pointer implementation in OCaml using jsont
0
fork
atom
overview
issues
pulls
pipelines
readme
anil.recoil.org
2 months ago
6b2ce026
013926e1
+57
1 changed file
expand all
collapse all
unified
split
README.md
+57
README.md
···
1
1
+
# json-pointer - RFC 6901 JSON Pointer for OCaml
2
2
+
3
3
+
A complete RFC 6901 JSON Pointer implementation for OCaml, providing parsing,
4
4
+
serialization, evaluation, and mutation operations compatible with jsont
5
5
+
codecs.
6
6
+
7
7
+
## Key Features
8
8
+
9
9
+
- Full RFC 6901 compliance with proper escape sequence handling
10
10
+
- Type-safe phantom types distinguish navigation vs append pointers
11
11
+
- Mutation operations for RFC 6902 JSON Patch support
12
12
+
- JMAP extended pointers (RFC 8620) with wildcard support
13
13
+
14
14
+
## Usage
15
15
+
16
16
+
```ocaml
17
17
+
(* Parse and evaluate a JSON Pointer *)
18
18
+
let json = Jsont_bytesrw.decode_string Jsont.json
19
19
+
{|{"foo": ["bar", "baz"], "a/b": 1}|} |> Result.get_ok
20
20
+
21
21
+
let value = Json_pointer.(get (of_string_nav "/foo/0") json)
22
22
+
(* value = Jsont.String ("bar", _) *)
23
23
+
24
24
+
(* Escape sequences: ~1 for /, ~0 for ~ *)
25
25
+
let value = Json_pointer.(get (of_string_nav "/a~1b") json)
26
26
+
(* value = Jsont.Number ("1", _) *)
27
27
+
```
28
28
+
29
29
+
Mutations for JSON Patch operations:
30
30
+
31
31
+
```ocaml
32
32
+
(* Add a new element to an array *)
33
33
+
let json' = Json_pointer.(add (of_string "/foo/-") json
34
34
+
~value:(Jsont.Json.string "qux"))
35
35
+
36
36
+
(* Remove an element *)
37
37
+
let json' = Json_pointer.(remove (of_string_nav "/foo/0") json)
38
38
+
```
39
39
+
40
40
+
## Installation
41
41
+
42
42
+
```
43
43
+
opam install json-pointer
44
44
+
```
45
45
+
46
46
+
## Documentation
47
47
+
48
48
+
API documentation is available via:
49
49
+
50
50
+
```
51
51
+
opam install json-pointer
52
52
+
odig doc json-pointer
53
53
+
```
54
54
+
55
55
+
## License
56
56
+
57
57
+
ISC