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