Safe Haskell | None |
---|---|
Language | Haskell2010 |
- merge :: [Value] -> Value
- flatToJSON :: (Generic a, GToJSON Zero (Rep a)) => Text -> a -> Value
- flatParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Text -> Value -> Parser a
- fieldToJSON :: (Generic a, GToJSON Zero (Rep a)) => Text -> a -> Value
- fieldParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Text -> Value -> Parser a
Documentation
merge :: [Value] -> Value Source #
Merge values together. Useful for creating compound JSON structures that should be parsed as one object
data A = A { one :: String, two :: String } deriving (Show, Eq, Generic) instance ToJSON A instance FromJSON A data B = B { three :: String } deriving (Show, Eq, Generic) instance ToJSON B instance FromJSON B data AB = AB A B deriving (Show, Eq) instance ToJSON AB where toJSON (AB a b) = merge [toJSON a, toJSON b] instance FromJSON AB where parseJSON o = do a <- parseJSON o b <- parseJSON o return $ AB a b