Something went wrong. Try again.
RFC6901 JSON Pointer implementation in OCaml using jsont
Something went wrong. Try again.
5 files
README.md
6-jmap #
RFC 8620 result references
extend pointer evaluation with one rule: when the current value is an array,
the * token applies the remaining pointer to every element. Array results are
flattened by one level.
The pointer type and parser do not change. Choose Json_pointer.Jmap.get only
at evaluation time:
let ids =
Json_pointer.Jmap.get
(Json_pointer.of_string "/list/*/id")
response
let typed_ids =
Jsont.Json.decode'
(Json_pointer.Jmap.path_list
(Json_pointer.of_string "/list/*/id")
Jsont.string)
response
|> Result.get_ok
Run the complete example:
$ cd example/6-jmap
$ opam install --deps-only --yes .
$ dune exec --root . ./jmap.exe
ids: ["a","b"]
flattened tags: ["x","y","z"]
typed ids: [a; b]
object wildcard: "literal member"
The final line is deliberate: * is special only while traversing an array.
On an object, it remains the ordinary member name "*". Use the non-JMAP
functions everywhere that RFC 8620 wildcard semantics are not wanted.
Next steps #
- Return to the tutorial index to revisit any stage.
- Continue with the full odoc tutorial or the
Json_pointerinterface.
Folders and files #
jmap.mlis the complete program.dunedescribes its executable.dune-projectand6-jmap.opammake this a standalone project.