json-syntax-0.2.3.0: High-performance JSON parser and encoder
Safe HaskellSafe-Inferred
LanguageHaskell2010

Json

Synopsis

Types

data Value Source #

The JSON syntax tree described by the ABNF in RFC 7159. Notable design decisions include:

  • True and False are their own data constructors rather than being lumped together under a data constructor for boolean values. This improves performance when decoding the syntax tree to a Bool.
  • Object uses an association list rather than a hash map. This is the data type that key-value pairs can be parsed into most cheaply.
  • Object and Array both use Chunks rather than using SmallArray or cons-list directly. This a middle ground between those two types. We get the efficent use of cache lines that SmallArray offers, and we get the worst-case O(1) appends that cons-list offers. Users will typically fold over the elements with the Foldable instance of Chunks, although there are functions in Data.Chunks that efficently perform other operations.

Instances

Instances details
Show Value Source # 
Instance details

Defined in Json

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Eq Value Source # 
Instance details

Defined in Json

Methods

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

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

data Member Source #

A key-value pair in a JSON object. The name of this type is taken from section 4 of RFC 7159.

Constructors

Member 

Fields

Instances

Instances details
Show Member Source # 
Instance details

Defined in Json

Eq Member Source # 
Instance details

Defined in Json

Methods

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

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

data SyntaxException Source #

Exceptions that can happen while parsing JSON. Do not pattern match on values of this type. New data constructors may be added at any time without a major version bump.

Functions

decode :: Bytes -> Either SyntaxException Value Source #

Decode a JSON syntax tree from a byte sequence.

encode :: Value -> Builder Source #

Encode a JSON syntax tree.

Infix Synonyms

pattern (:->) :: ShortText -> Value -> Member Source #

Infix pattern synonym for Member.

Constants

emptyArray :: Value Source #

An array with no elements (i.e. [])

emptyObject :: Value Source #

An object with no members (i.e. {})

Construction

object1 :: Member -> Value Source #

Construct a JSON object with one member.

object2 :: Member -> Member -> Value Source #

Construct a JSON object with two members.

object3 :: Member -> Member -> Member -> Value Source #

Construct a JSON object with three members.

object4 :: Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with four members.

object5 :: Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with five members.

object6 :: Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with six members.

object7 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with seven members.

object8 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with nine members.

object9 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with nine members.

object10 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with ten members.

object11 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with eleven members.

object12 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value Source #

Construct a JSON object with twelve members.