json-0.11: Support for serialising Haskell to and from JSON
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.JSON.Types

Description

Basic support for working with JSON values.

Synopsis

JSON Types

data JSValue Source #

JSON values

The type to which we encode Haskell values. There's a set of primitives, and a couple of heterogenous collection types.

Objects:

An object structure is represented as a pair of curly brackets surrounding zero or more name/value pairs (or members). A name is a string. A single colon comes after each name, separating the name from the value. A single comma separates a value from a following name.

Arrays:

An array structure is represented as square brackets surrounding zero or more values (or elements). Elements are separated by commas.

Only valid JSON can be constructed this way

Instances

Instances details
IsString JSValue Source # 
Instance details

Defined in Text.JSON.Types

Methods

fromString :: String -> JSValue #

Read JSValue Source # 
Instance details

Defined in Text.JSON.Types

Show JSValue Source # 
Instance details

Defined in Text.JSON.Types

Eq JSValue Source # 
Instance details

Defined in Text.JSON.Types

Methods

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

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

Ord JSValue Source # 
Instance details

Defined in Text.JSON.Types

JSON JSValue Source #

To ensure we generate valid JSON, we map Haskell types to JSValue internally, then pretty print that.

Instance details

Defined in Text.JSON

Wrapper Types

newtype JSString Source #

Strings can be represented a little more efficiently in JSON

Constructors

JSONString 

Fields

Instances

Instances details
IsString JSString Source # 
Instance details

Defined in Text.JSON.Types

Read JSString Source # 
Instance details

Defined in Text.JSON.Types

Show JSString Source # 
Instance details

Defined in Text.JSON.Types

Eq JSString Source # 
Instance details

Defined in Text.JSON.Types

Ord JSString Source # 
Instance details

Defined in Text.JSON.Types

JSKey JSString Source # 
Instance details

Defined in Text.JSON

JSON JSString Source # 
Instance details

Defined in Text.JSON

toJSString :: String -> JSString Source #

Turn a Haskell string into a JSON string.

newtype JSObject e Source #

As can association lists

Constructors

JSONObject 

Fields

Instances

Instances details
Read e => Read (JSObject e) Source # 
Instance details

Defined in Text.JSON.Types

Show e => Show (JSObject e) Source # 
Instance details

Defined in Text.JSON.Types

Methods

showsPrec :: Int -> JSObject e -> ShowS #

show :: JSObject e -> String #

showList :: [JSObject e] -> ShowS #

Eq e => Eq (JSObject e) Source # 
Instance details

Defined in Text.JSON.Types

Methods

(==) :: JSObject e -> JSObject e -> Bool #

(/=) :: JSObject e -> JSObject e -> Bool #

Ord e => Ord (JSObject e) Source # 
Instance details

Defined in Text.JSON.Types

Methods

compare :: JSObject e -> JSObject e -> Ordering #

(<) :: JSObject e -> JSObject e -> Bool #

(<=) :: JSObject e -> JSObject e -> Bool #

(>) :: JSObject e -> JSObject e -> Bool #

(>=) :: JSObject e -> JSObject e -> Bool #

max :: JSObject e -> JSObject e -> JSObject e #

min :: JSObject e -> JSObject e -> JSObject e #

JSON a => JSON (JSObject a) Source # 
Instance details

Defined in Text.JSON

toJSObject :: [(String, a)] -> JSObject a Source #

Make JSON object out of an association list.

get_field :: JSObject a -> String -> Maybe a Source #

Get the value of a field, if it exist.

set_field :: JSObject a -> String -> a -> JSObject a Source #

Set the value of a field. Previous values are overwritten.