| Copyright | (c) Michael Ledger 2026 |
|---|---|
| License | MPL-2.0 |
| Maintainer | Michael Ledger <mike@quasimal.com> |
| Safe Haskell | None |
| Language | GHC2021 |
Data.Aeson.RecordAsTuple
Description
Synopsis
- newtype RecordAsTuple a = RecordAsTuple a
Documentation
newtype RecordAsTuple a Source #
Use this with -XDerivingVia to derive aeson decoders and encoders for
record types which encode the record as a JSON array rather than object.
Examples >>> data P = P {x,y,z,w::Float} deriving stock (Show,Generic) deriving (ToJSON,FromJSON) via (RecordAsTuple P) >>> JSON.toJSON (P 1 2 3 4) Array [Number 1.0,Number 2.0,Number 3.0,Number 4.0] >>> JSON.fromJSON @P (JSON.toJSON (P 1 2 3 4)) Success (P {x = 1.0, y = 2.0, z = 3.0, w = 4.0}) >>> data T = T {a,b,c::Float} deriving stock (Generic) >>> JSON.toJSON (RecordAsTuple (T 1 2 3)) Array [Number 1.0,Number 2.0,Number 3.0]
Constructors
| RecordAsTuple a |