If I can make a small off-topic remark, I think it’s wrong to create custom syntax for generating type-oriented code when there are already two different syntaxes (one for type_conv and one for output), one of which (type-conv) becomes the de facto standard.
type foo = { ... } with json
If you choose the syntax for this, you should use it unless you have very good reasons. In fact, type-conv itself is a helper utility that allows you to write your own type-oriented code generators, so you can also use type-conv directly for what you're trying to do.
(You probably know about Martin Jambon Atdgen , who made a conscious choice not to use Camlp4, Allen Frisch's work continues to support annotations directly in OCaml syntax, but which is not yet ready for consumption.)
source share