Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Value
- = Object !(SmallArray Member)
- | Array !(SmallArray Value)
- | String !ShortText
- | Number !Scientific
- | Null
- | True
- | False
- data Member = Member {}
- data SyntaxException
- = EmptyInput
- | ExpectedColon
- | ExpectedCommaOrRightBracket
- | ExpectedFalse
- | ExpectedNull
- | ExpectedQuote
- | ExpectedQuoteOrRightBrace
- | ExpectedTrue
- | IncompleteArray
- | IncompleteEscapeSequence
- | IncompleteObject
- | IncompleteString
- | InvalidEscapeSequence
- | InvalidLeader
- | InvalidNumber
- | LeadingZero
- | UnexpectedLeftovers
- decode :: Bytes -> Either SyntaxException Value
- encode :: Value -> Builder
- pattern (:->) :: ShortText -> Value -> Member
- emptyArray :: Value
- emptyObject :: Value
- object1 :: Member -> Value
- object2 :: Member -> Member -> Value
- object3 :: Member -> Member -> Member -> Value
- object4 :: Member -> Member -> Member -> Member -> Value
- object5 :: Member -> Member -> Member -> Member -> Member -> Value
- object6 :: Member -> Member -> Member -> Member -> Member -> Member -> Value
- object7 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
- object8 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
- object9 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
- object10 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
- object11 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
- object12 :: Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Member -> Value
Types
The JSON syntax tree described by the ABNF in RFC 7159. Notable design decisions include:
True
andFalse
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 aBool
.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
andArray
both useChunks
rather than usingSmallArray
or cons-list directly. This a middle ground between those two types. We get the efficent use of cache lines thatSmallArray
offers, and we get the worst-caseO(1)
appends that cons-list offers. Users will typically fold over the elements with theFoldable
instance ofChunks
, although there are functions inData.Chunks
that efficently perform other operations.
A key-value pair in a JSON object. The name of this type is taken from section 4 of RFC 7159.
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.
Instances
Exception SyntaxException Source # | |
Defined in Json | |
Show SyntaxException Source # | |
Defined in Json showsPrec :: Int -> SyntaxException -> ShowS # show :: SyntaxException -> String # showList :: [SyntaxException] -> ShowS # | |
Eq SyntaxException Source # | |
Defined in Json (==) :: SyntaxException -> SyntaxException -> Bool # (/=) :: SyntaxException -> SyntaxException -> Bool # |
Functions
decode :: Bytes -> Either SyntaxException Value Source #
Decode a JSON syntax tree from a byte sequence.
Infix Synonyms
Constants
emptyArray :: Value Source #
An array with no elements (i.e. []
)
emptyObject :: Value Source #
An object with no members (i.e. {}
)
Construction
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.