Re:The Serde Rust Framework
by dwohnitmok on Thursday October 14, 2021 @11:27PM
(#28873873)
> In Haskell it's a bit more awkward, but you can kinda pull something similar off in terms of ergonomics. I've not worked with JSON in Haskell that much that I need to look for it, but I don't remember there being something as ergonomic as serde.
I think Haskell's most popular JSON library aeson is basically the same thing and probably a source of inspiration for serde.
data MyCustomType = ... deriving (Generic, ToJSON, FromJSON)
or if you want more control you can use deriving-aeson
-- I prefer snake case instead
data MyCustomType = ...
deriving Generic
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier CamelToSnake]
I think Haskell's most popular JSON library aeson is basically the same thing and probably a source of inspiration for serde.
or if you want more control you can use deriving-aeson