hjson-1.3.2: JSON parsing library

Text.HJson

Contents

Synopsis

JSON data type

fromString :: String -> Either ParseError JsonSource

Parses JSON string

toString :: Json -> StringSource

Renders JSON to String

escapeJString :: String -> StringSource

Escapes string for inclusion in JSON

jsonParser :: Monad m => ParsecT String s m JsonSource

Parsec parser for JSON

Type class for objects [de]serialization

class Jsonable a whereSource

Class of types that can be converted to or from JSON

Methods

toJson :: a -> JsonSource

Convert value to JSON representation

fromJson :: Json -> Maybe aSource

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

newtype List a Source

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

Constructors

List 

Fields

asList :: [a]
 

Instances

Eq a => Eq (List a) 
Ord a => Ord (List a) 
Show a => Show (List a) 
Jsonable a => Jsonable (List a) 

newtype Object a Source

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

asMap :: Map String a
 

Instances

Eq a => Eq (Object a) 
Show a => Show (Object a) 
Jsonable a => Jsonable (Object a) 

newtype LaxObject a Source

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

Constructors

LaxObject 

Fields

asLaxMap :: Map String a
 

Instances

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