hjson-1.3.2: JSON parsing library

Safe HaskellSafe
LanguageHaskell98

Text.HJson

Contents

Synopsis

JSON data type

data Json #

Instances

Eq Json # 

Methods

(==) :: Json -> Json -> Bool #

(/=) :: Json -> Json -> Bool #

Data Json # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Json -> c Json #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Json #

toConstr :: Json -> Constr #

dataTypeOf :: Json -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Json) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Json) #

gmapT :: (forall b. Data b => b -> b) -> Json -> Json #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Json -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Json -> r #

gmapQ :: (forall d. Data d => d -> u) -> Json -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Json -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Json -> m Json #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Json -> m Json #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Json -> m Json #

Show Json # 

Methods

showsPrec :: Int -> Json -> ShowS #

show :: Json -> String #

showList :: [Json] -> ShowS #

Jsonable Json # 

Methods

toJson :: Json -> Json #

fromJson :: Json -> Maybe Json #

fromString :: String -> Either ParseError Json #

Parses JSON string

toString :: Json -> String #

Renders JSON to String

escapeJString :: String -> String #

Escapes string for inclusion in JSON

jsonParser :: Monad m => ParsecT String s m Json #

Parsec parser for JSON

Type class for objects [de]serialization

class Jsonable a where #

Class of types that can be converted to or from JSON

Minimal complete definition

toJson

Methods

toJson :: a -> Json #

Convert value to JSON representation

fromJson :: Json -> Maybe a #

Deserialize value. Returns Nothing in case of failure. Default implementation always returns Nothing

Instances

Jsonable Bool # 

Methods

toJson :: Bool -> Json #

fromJson :: Json -> Maybe Bool #

Jsonable Double # 
Jsonable Float # 

Methods

toJson :: Float -> Json #

fromJson :: Json -> Maybe Float #

Jsonable Int # 

Methods

toJson :: Int -> Json #

fromJson :: Json -> Maybe Int #

Jsonable Integer # 
Jsonable String # 
Jsonable IntSet # 
Jsonable Json # 

Methods

toJson :: Json -> Json #

fromJson :: Json -> Maybe Json #

Jsonable a => Jsonable (Maybe a) # 

Methods

toJson :: Maybe a -> Json #

fromJson :: Json -> Maybe (Maybe a) #

Jsonable a => Jsonable (IntMap a) # 

Methods

toJson :: IntMap a -> Json #

fromJson :: Json -> Maybe (IntMap a) #

Jsonable a => Jsonable (Seq a) # 

Methods

toJson :: Seq a -> Json #

fromJson :: Json -> Maybe (Seq a) #

(Jsonable a, Ord a) => Jsonable (Set a) # 

Methods

toJson :: Set a -> Json #

fromJson :: Json -> Maybe (Set a) #

Jsonable a => Jsonable (LaxObject a) # 

Methods

toJson :: LaxObject a -> Json #

fromJson :: Json -> Maybe (LaxObject a) #

Jsonable a => Jsonable (Object a) # 

Methods

toJson :: Object a -> Json #

fromJson :: Json -> Maybe (Object a) #

Jsonable a => Jsonable (List a) # 

Methods

toJson :: List a -> Json #

fromJson :: Json -> Maybe (List a) #

(Jsonable a, Jsonable b) => Jsonable (Either a b) # 

Methods

toJson :: Either a b -> Json #

fromJson :: Json -> Maybe (Either a b) #

(Jsonable a, Jsonable b) => Jsonable (a, b) # 

Methods

toJson :: (a, b) -> Json #

fromJson :: Json -> Maybe (a, b) #

(Jsonable a, Ord a, Jsonable b) => Jsonable (Map a b) # 

Methods

toJson :: Map a b -> Json #

fromJson :: Json -> Maybe (Map a b) #

(Jsonable a, Jsonable b, Jsonable c) => Jsonable (a, b, c) # 

Methods

toJson :: (a, b, c) -> Json #

fromJson :: Json -> Maybe (a, b, c) #

(Jsonable a, Jsonable b, Jsonable c, Jsonable d) => Jsonable (a, b, c, d) # 

Methods

toJson :: (a, b, c, d) -> Json #

fromJson :: Json -> Maybe (a, b, c, d) #

(Jsonable a, Jsonable b, Jsonable c, Jsonable d, Jsonable e) => Jsonable (a, b, c, d, e) # 

Methods

toJson :: (a, b, c, d, e) -> Json #

fromJson :: Json -> Maybe (a, b, c, d, e) #

newtype List a #

Newtype wrapper for list. It's user to avoid overlapping instances for string

Constructors

List 

Fields

Instances

Eq a => Eq (List a) # 

Methods

(==) :: List a -> List a -> Bool #

(/=) :: List a -> List a -> Bool #

Ord a => Ord (List a) # 

Methods

compare :: List a -> List a -> Ordering #

(<) :: List a -> List a -> Bool #

(<=) :: List a -> List a -> Bool #

(>) :: List a -> List a -> Bool #

(>=) :: List a -> List a -> Bool #

max :: List a -> List a -> List a #

min :: List a -> List a -> List a #

Show a => Show (List a) # 

Methods

showsPrec :: Int -> List a -> ShowS #

show :: List a -> String #

showList :: [List a] -> ShowS #

Jsonable a => Jsonable (List a) # 

Methods

toJson :: List a -> Json #

fromJson :: Json -> Maybe (List a) #

newtype Object a #

Newtype wrapper for Map String a. Similarly it's used to avoid overlapping instances for more generic Map a b instance.

Jsonable instance for this type require that every JSON value in map should be properly decoded.

Constructors

Object 

Fields

Instances

Eq a => Eq (Object a) # 

Methods

(==) :: Object a -> Object a -> Bool #

(/=) :: Object a -> Object a -> Bool #

Show a => Show (Object a) # 

Methods

showsPrec :: Int -> Object a -> ShowS #

show :: Object a -> String #

showList :: [Object a] -> ShowS #

Jsonable a => Jsonable (Object a) # 

Methods

toJson :: Object a -> Json #

fromJson :: Json -> Maybe (Object a) #

newtype LaxObject a #

Another wrapper for Map String a. It have different Jsonable instance. Undecodable values in JObject are ignored.

Constructors

LaxObject 

Fields

Instances

Eq a => Eq (LaxObject a) # 

Methods

(==) :: LaxObject a -> LaxObject a -> Bool #

(/=) :: LaxObject a -> LaxObject a -> Bool #

Show a => Show (LaxObject a) # 
Jsonable a => Jsonable (LaxObject a) # 

Methods

toJson :: LaxObject a -> Json #

fromJson :: Json -> Maybe (LaxObject a) #