Copyright | (c) Anton Gushcha 2016 |
---|---|
License | MIT |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
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
Bounded Unit Source # | |
Enum Unit Source # | |
Eq Unit Source # | |
Read Unit Source # | |
Show Unit Source # | |
Generic Unit Source # | |
ToJSON Unit Source # | |
Defined in Data.Aeson.Unit | |
FromJSON Unit Source # | Always a success parse |
ToSchema Unit Source # | |
Defined in Data.Aeson.Unit Methods declareNamedSchema :: Proxy Unit -> Declare (Definitions Schema) NamedSchema # | |
type Rep Unit Source # | |