aeson-extra-0.4.0.0: Extra goodies for aeson

Copyright | (C) 2015-2016 Oleg Grenrus
License | BSD3
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi>
Safe Haskell | None
Language | Haskell2010

Data.Aeson.Extra.Map

Description

Deprecated: Use aeson-1 TOJSONKey etc functionality

More or less useful newtypes for writing `FromJSON` & `ToJSON` instances

Synopsis

- newtype M a = M {
  - getMap :: a
  }
- class FromJSONKey a where
- parseIntegralJSONKey :: Integral a => Text -> Parser a
- class FromJSONMap m k v | m -> k v where
- class ToJSONKey a where
- class ToJSONMap m k v | m -> k v where

# Documentation

newtype M a Source #

A wrapper type to parse arbitrary maps

    λ > decode "{\"1\": 1, \"2\": 2}" :: Maybe (M (H.HashMap Int Int))
    Just (M {getMap = fromList [(1,1),(2,2)]})

Constructors

M |

Fields

- getMap :: a

Instances

Functor M Source # |
Methods fmap :: (a -> b) -> M a -> M b # (<$) :: a -> M b -> M a #
Foldable M Source # |

Methods

fold :: Monoid m => M m -> m #

foldMap :: Monoid m => (a -> m) -> M a -> m #

foldr :: (a -> b -> b) -> b -> M a -> b #

foldr' :: (a -> b -> b) -> b -> M a -> b #

foldl :: (b -> a -> b) -> b -> M a -> b #

foldl' :: (b -> a -> b) -> b -> M a -> b #

foldr1 :: (a -> a -> a) -> M a -> a #

foldl1 :: (a -> a -> a) -> M a -> a #

toList :: M a -> [a] #

null :: M a -> Bool #

length :: M a -> Int #

elem :: Eq a => a -> M a -> Bool #

maximum :: Ord a => M a -> a #

minimum :: Ord a => M a -> a #

sum :: Num a => M a -> a #

product :: Num a => M a -> a #

Traversable M Source # |
Methods traverse :: Applicative f => (a -> f b) -> M a -> f (M b) # sequenceA :: Applicative f => M (f a) -> f (M a) # mapM :: Monad m => (a -> m b) -> M a -> m (M b) # sequence :: Monad m => M (m a) -> m (M a) #
Eq a => Eq (M a) Source # |
Methods (==) :: M a -> M a -> Bool # (/=) :: M a -> M a -> Bool #
Ord a => Ord (M a) Source # |
Methods compare :: M a -> M a -> Ordering # (<) :: M a -> M a -> Bool # (<=) :: M a -> M a -> Bool # (>) :: M a -> M a -> Bool # (>=) :: M a -> M a -> Bool # max :: M a -> M a -> M a # min :: M a -> M a -> M a #
Read a => Read (M a) Source # |
Methods readsPrec :: Int -> ReadS (M a) # readList :: ReadS [M a] # readPrec :: ReadPrec (M a) # readListPrec :: ReadPrec [M a] #
Show a => Show (M a) Source # |
Methods showsPrec :: Int -> M a -> ShowS # show :: M a -> String # showList :: [M a] -> ShowS #
ToJSONMap m k v => ToJSON (M m) Source # |
Methods toJSON :: M m -> Value # toEncoding :: M m -> Encoding # toJSONList :: [M m] -> Value # toEncodingList :: [M m] -> Encoding #
FromJSONMap m k v => FromJSON (M m) Source # |
Methods parseJSON :: Value -> Parser (M m) # parseJSONList :: Value -> Parser [M m] #

class FromJSONKey a where Source #

Minimal complete definition

parseJSONKey

Methods

parseJSONKey :: Text -> Parser a Source #

Instances

FromJSONKey Int Source # |
Methods parseJSONKey :: Text -> Parser Int Source #
FromJSONKey Integer Source # |
Methods parseJSONKey :: Text -> Parser Integer Source #
FromJSONKey String Source # |
Methods parseJSONKey :: Text -> Parser String Source #
FromJSONKey Text Source # |
Methods parseJSONKey :: Text -> Parser Text Source #
FromJSONKey Text Source # |
Methods parseJSONKey :: Text -> Parser Text Source #

parseIntegralJSONKey :: Integral a => Text -> Parser a Source #

class FromJSONMap m k v | m -> k v where Source #

Minimal complete definition

parseJSONMap

Methods

parseJSONMap :: HashMap Text Value -> Parser m Source #

Instances

(Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSONMap (HashMap k v) k v Source # |
Methods parseJSONMap :: HashMap Text Value -> Parser (HashMap k v) Source #
(Ord k, FromJSONKey k, FromJSON v) => FromJSONMap (Map k v) k v Source # |
Methods parseJSONMap :: HashMap Text Value -> Parser (Map k v) Source #

class ToJSONKey a where Source #

Minimal complete definition

toJSONKey

Methods

toJSONKey :: a -> Text Source #

Instances

ToJSONKey Int Source # |
Methods toJSONKey :: Int -> Text Source #
ToJSONKey Integer Source # |
Methods toJSONKey :: Integer -> Text Source #
ToJSONKey String Source # |
Methods toJSONKey :: String -> Text Source #
ToJSONKey Text Source # |
Methods toJSONKey :: Text -> Text Source #
ToJSONKey Text Source # |
Methods toJSONKey :: Text -> Text Source #

class ToJSONMap m k v | m -> k v where Source #

Minimal complete definition

toJSONMap

Methods

toJSONMap :: m -> HashMap Text Value Source #

Instances

(ToJSONKey k, ToJSON v) => ToJSONMap (HashMap k v) k v Source # |
Methods toJSONMap :: HashMap k v -> HashMap Text Value Source #
(ToJSONKey k, ToJSON v) => ToJSONMap (Map k v) k v Source # |
Methods toJSONMap :: Map k v -> HashMap Text Value Source #