-
Notifications
You must be signed in to change notification settings - Fork 15
Tl;DR
Anders Peter Fugmann edited this page Apr 15, 2019
·
1 revision
install the package through opam:
opam install ppx_protocol_conv_json
Create a dune
file with the contents:
(executable
(name test)
(modules test)
(libraries ppx_protocol_conv_json yojson)
(preprocess (pps ppx_protocol_conv)))
And a test.ml
file with the contents:
open Protocol_conv_json
type t = A of int | B of float
[@@deriving protocol ~driver:(module Json)]
let () =
let t = A 5
let json = to_json t in
Printf.printf "t serialized: %s\n" (Yojson.Safe.to_string json);
let t' = of_json json in
print_endline "Done!"
The above example uses the Json
driver to serialize / deserialize
The following drivers are provided: