serde-ml / serde

Serialization framework for OCaml
MIT License
174 stars 11 forks source link

Support tagging modes #20

Open leostera opened 8 months ago

leostera commented 8 months ago

When serializing/deserializing values of a variant type, we'd like the constructor name placement to be configurable.

type user [@@serde {tag = "type"}]

On an variant: Use the internally tagged enum representation, with the given tag. On a record: Serialize the record name as a field with the given key, in front of all the real fields of the struct.

type user [@@serde {tag = "t"; content = "c"}]
type user [@@serde { untagged }]