| Copyright | (c) Anton Gushcha 2016 |
|---|---|
| License | MIT |
| Maintainer | ncrashed@gmail.com |
| Stability | experimental |
| Portability | Portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Aeson.Unit
Description
Common problem in REST interfaces when you need to return nothing as result,
usage of () will produce `[]` JSON. That causes problems in some JSON parsers
in other languages.
So, Unit serialises into empty JSON object:
>>>encode Unit"{}"
Documentation
Data type that serialise into empty object in aeson
>>>encode Unit"{}"
>>>encode $ toSchema (Proxy :: Proxy Unit)"{\"type\":\"object\"}"
Also the FromJSON instance is just `pure Unit`, so it never fails.
Constructors
| Unit |
Instances
| FromJSON Unit Source # | Always a success parse |
| ToJSON Unit Source # | |
Defined in Data.Aeson.Unit | |
| Bounded Unit Source # | |
| Enum Unit Source # | |
| Generic Unit Source # | |
| Read Unit Source # | |
| Show Unit Source # | |
| Eq Unit Source # | |
| ToSchema Unit Source # | |
Defined in Data.Aeson.Unit Methods declareNamedSchema :: Proxy Unit -> Declare (Definitions Schema) NamedSchema # | |
| type Rep Unit Source # | |