stdio-0.2.0.0: A simple and high performance IO toolkit for Haskell

Copyright(c) Dong Han 2019
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Std.Data.JSON.Builder

Contents

Description

This module provides builders for JSON Values, a Haskell JSON representation. These builders are designed to comply with rfc8258. Only control characters are escaped, other unicode codepoints are directly written instead of being escaped.

Synopsis

Value Builders

object' :: (a -> Builder ()) -> Vector (Text, a) -> Builder () Source #

array' :: (a -> Builder ()) -> Vector a -> Builder () Source #

Builder helpers

kv :: Text -> Builder () -> Builder () Source #

Use : as separator to connect a label(no need to escape, only add quotes) with field builders.

kv' :: Text -> Builder () -> Builder () Source #

Use : as separator to connect a label(escaped and add quotes) with field builders.

Re-export Value type

data Value Source #

A JSON value represented as a Haskell value.

The Object's payload is a key-value vector instead of a map, which parsed directly from JSON document. This design choice has following advantages:

  • Allow different strategies handling duplicated keys.
  • Allow different Map type to do further parsing, e.g. FlatMap
  • Roundtrip without touching the original key-value order.
  • Save time if constructing map is not neccessary, e.g. using a linear scan to find a key if only that key is needed.

Constructors

Object !(Vector (Text, Value)) 
Array !(Vector Value) 
String !Text 
Number !Scientific 
Bool !Bool 
Null 
Instances
Eq Value Source # 
Instance details

Defined in Std.Data.JSON.Value

Methods

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

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

Show Value Source # 
Instance details

Defined in Std.Data.JSON.Value

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Generic Value Source # 
Instance details

Defined in Std.Data.JSON.Value

Associated Types

type Rep Value :: Type -> Type #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

NFData Value Source # 
Instance details

Defined in Std.Data.JSON.Value

Methods

rnf :: Value -> () #

Arbitrary Value Source # 
Instance details

Defined in Std.Data.JSON.Value

Methods

arbitrary :: Gen Value

shrink :: Value -> [Value]

ToText Value Source # 
Instance details

Defined in Std.Data.JSON.Value

FromValue Value Source # 
Instance details

Defined in Std.Data.JSON.Base

EncodeJSON Value Source # 
Instance details

Defined in Std.Data.JSON.Base

Methods

encodeJSON :: Value -> Builder () Source #

ToValue Value Source # 
Instance details

Defined in Std.Data.JSON.Base

Methods

toValue :: Value -> Value Source #

type Rep Value Source # 
Instance details

Defined in Std.Data.JSON.Value