Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype JsonEndo a = JsonEndo {
- unJsonEndo :: [a] -> [a]
- newtype WithJsonKeyValues a = WithJsonKeyValues {
- unWithJsonKeyValues :: a
- class ToJsonKeyValues a where
- toJsonKeyValues :: (KeyValue kv, Monoid kv) => a -> [kv]
- objectWithoutNulls :: [Pair] -> Value
- readJson :: Read a => String -> String -> Parser a
- objectEndo :: [JsonEndo Pair] -> Value
- (.?=) :: (KeyValue p, ToJSON v, Monoid p) => Key -> Maybe v -> p
- (.!=) :: (KeyValue kv, ToJSON v) => Key -> v -> kv
Documentation
JsonEndo | |
|
newtype WithJsonKeyValues a Source #
For use with language extension DerivingVia. This derivation provides a ToJSON instance that delegates to the ToJsonKeyValues instance.
For example:
newtype MyType = MyType { myField :: Text } deriving J.ToJSON via WithJsonKeyValues MyType
Instances
ToJsonKeyValues a => ToJSON (WithJsonKeyValues a) Source # | |
Defined in HaskellWorks.Data.Aeson toJSON :: WithJsonKeyValues a -> Value # toEncoding :: WithJsonKeyValues a -> Encoding # toJSONList :: [WithJsonKeyValues a] -> Value # toEncodingList :: [WithJsonKeyValues a] -> Encoding # |
class ToJsonKeyValues a where Source #
Generate key values from a value of a type. This can be used
in conjunction with WithJsonKeyValues
to define a ToJSON
instance
without having to implement both toJSON
and toEncoding
, thereby
reducing boilerplate.
For example:
instance ToJsonEncoding MyType where toJsonEncoding sv = [ "my_field" .!= sv ^. #myField ]
toJsonKeyValues :: (KeyValue kv, Monoid kv) => a -> [kv] Source #
objectWithoutNulls :: [Pair] -> Value Source #