| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Row.Aeson
Contents
Description
This module defines orphan aeson instances for Row.
They differ from the instances in `row-types-aeson` in one crucial respect: they
serialise Nothing fields by *omitting* them in the resulting object, and parse absent fields as Nothing.
aeson can be configured to have this behviour for instances for datatypes, but we want to do this
for record types generically.
This is crucial to match what LSP clients expect.
Synopsis
- class ToJSONEntry a where
- toJSONEntry :: String -> a -> Object
- class FromJSONEntry a where
- parseJSONEntry :: Object -> String -> Parser a
- lazyUncons :: KnownSymbol l => Label l -> Rec r -> (Rec (r .- l), r .! l)
Documentation
class ToJSONEntry a where Source #
Serialise a value as an entry in a JSON object. This allows customizing the behaviour in the object context, in order to e.g. omit the field.
Methods
toJSONEntry :: String -> a -> Object Source #
Instances
| ToJSON a => ToJSONEntry a Source # | |
Defined in Data.Row.Aeson Methods toJSONEntry :: String -> a -> Object Source # | |
| ToJSON a => ToJSONEntry (Maybe a) Source # | |
Defined in Data.Row.Aeson | |
class FromJSONEntry a where Source #
Instances
| FromJSON a => FromJSONEntry a Source # | |
Defined in Data.Row.Aeson | |
| FromJSON a => FromJSONEntry (Maybe a) Source # | |
Defined in Data.Row.Aeson | |
lazyUncons :: KnownSymbol l => Label l -> Rec r -> (Rec (r .- l), r .! l) Source #
Orphan instances
| (AllUniqueLabels r, Forall r FromJSONEntry) => FromJSON (Rec r) Source # | |
| Forall r ToJSONEntry => ToJSON (Rec r) Source # | |