Give aliases to record fields.
by-other-names
Give aliases to record fields.
When generically deriving aeson's FromJSON
and ToJSON
instances, field names are used as the keys for the serialized JSON. If you don't want that, another option is to write the instances manually. Problem is, you have to repeat the field names once for FromJSON
and once for ToJSON
.
I wanted an intermediate solution similar to what is provided by Go's struct tags: associate aliases with each field and use those aliases when serializing/deserializing. There can be different sets of aliases for different contexts (json, orm...). In this library, each of those possible contexts is called a "rubric".
How to depend on this library?
build-depends:
by-other-names ^>= 1.2.3.0
Other related packages
autodocodec. A family of packages for deriving JSON and Openapi-related classes. More mature and fully-featured than this package. A blog post about it.