avro is the runtime library, should be reasonably small (depends only on camlzip)avro-compiler can read a json schema and generate code from itSee some examples from the tests/ directory:
tests/records.json and tests/records_test.ml that use it. you can see what the schema compiler will produce:
$ ./compiler.sh ./tests/records.json
(* generated by avro-compiler *)
open Avro
module Str_map = Map.Make(String)
let schema = "{\"type\":\"record\",\"name\":\"test\",\"fields\":[{\"type\":\"long\",\"name\":\"a\"},{
\"type\":\"string\",\"name\":\"b\"}]}"
type nonrec t = { a: int64; b: string; }
let read (input:Input.t) : t =
(let a = Input.read_int64 input in
let b = Input.read_string input in
{ a;b })
let write (out:Output.t) (self:t) : unit =
((let self = self.a in Output.write_int64 out self);
(let self = self.b in Output.write_string out self);
)tests/employee.json and tests/employee_test.ml that use it