json-0.11: Support for serialising Haskell to and from JSON

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.JSON.String

Contents

- Parsing
  - Reading JSON
  - Writing JSON

Description

Basic support for working with JSON values.

Synopsis

- data GetJSON a
- runGetJSON :: GetJSON a -> String -> Either String a
- readJSNull :: GetJSON JSValue
- readJSBool :: GetJSON JSValue
- readJSString :: GetJSON JSValue
- readJSRational :: GetJSON Rational
- readJSArray :: GetJSON JSValue
- readJSObject :: GetJSON JSValue
- readJSValue :: GetJSON JSValue
- readJSTopType :: GetJSON JSValue
- showJSNull :: ShowS
- showJSBool :: Bool -> ShowS
- showJSArray :: [JSValue] -> ShowS
- showJSObject :: JSObject JSValue -> ShowS
- showJSRational :: Rational -> ShowS
- showJSRational' :: Bool -> Rational -> ShowS
- showJSValue :: JSValue -> ShowS
- showJSTopType :: JSValue -> ShowS

# Parsing

data GetJSON a Source #

Parsing JSON

The type of JSON parsers for String

#### Instances

Instances details

MonadFail GetJSON Source # |
Instance details Defined in Text.JSON.String Methods fail :: String -> GetJSON a Source #
Applicative GetJSON Source # |
Instance details Defined in Text.JSON.String Methods pure :: a -> GetJSON a Source # (<*>) :: GetJSON (a -> b) -> GetJSON a -> GetJSON b Source # liftA2 :: (a -> b -> c) -> GetJSON a -> GetJSON b -> GetJSON c Source # (*>) :: GetJSON a -> GetJSON b -> GetJSON b Source # (<*) :: GetJSON a -> GetJSON b -> GetJSON a Source #
Functor GetJSON Source # |
Instance details Defined in Text.JSON.String Methods fmap :: (a -> b) -> GetJSON a -> GetJSON b Source # (<$) :: a -> GetJSON b -> GetJSON a Source #
Monad GetJSON Source # |
Instance details Defined in Text.JSON.String Methods (>>=) :: GetJSON a -> (a -> GetJSON b) -> GetJSON b Source # (>>) :: GetJSON a -> GetJSON b -> GetJSON b Source # return :: a -> GetJSON a Source #

runGetJSON :: GetJSON a -> String -> Either String a Source #

Run a JSON reader on an input String, returning some Haskell value. All input will be consumed.

## Reading JSON

readJSNull :: GetJSON JSValue Source #

Read the JSON null type

readJSBool :: GetJSON JSValue Source #

Read the JSON Bool type

readJSString :: GetJSON JSValue Source #

Read the JSON String type

readJSRational :: GetJSON Rational Source #

Read an Integer or Double in JSON format, returning a Rational

readJSArray :: GetJSON JSValue Source #

Read a list in JSON format

readJSObject :: GetJSON JSValue Source #

Read an object in JSON format

readJSValue :: GetJSON JSValue Source #

Read one of several possible JS types

readJSTopType :: GetJSON JSValue Source #

Top level JSON can only be Arrays or Objects

## Writing JSON

showJSNull :: ShowS Source #

Write the JSON null type

showJSBool :: Bool -> ShowS Source #

Write the JSON Bool type

showJSArray :: [JSValue] -> ShowS Source #

Show a list in JSON format

showJSObject :: JSObject JSValue -> ShowS Source #

Show an association list in JSON format

showJSRational :: Rational -> ShowS Source #

Show a Rational in JSON format

showJSRational' :: Bool -> Rational -> ShowS Source #

showJSValue :: JSValue -> ShowS Source #

Show JSON values

showJSTopType :: JSValue -> ShowS Source #

Writing JSON

Show strict JSON top level types. Values not permitted at the top level are wrapped in a singleton array.