aeson-0.6.0.2: Fast JSON parsing and encoding

Portabilityportable
Stabilityexperimental
MaintainerBryan O'Sullivan <bos@serpentine.com>
Safe HaskellSafe-Infered

Data.Aeson.Parser.Internal

Contents

Description

Efficiently and correctly parse a JSON string. The string must be encoded as UTF-8.

Synopsis

Lazy parsers

json :: Parser ValueSource

Parse a top-level JSON value. This must be either an object or an array, per RFC 4627.

The conversion of a parsed value to a Haskell value is deferred until the Haskell value is needed. This may improve performance if only a subset of the results of conversions are needed, but at a cost in thunk allocation.

value :: Parser ValueSource

Parse any JSON value. You should usually json in preference to this function, as this function relaxes the object-or-array requirement of RFC 4627.

In particular, be careful in using this function if you think your code might interoperate with Javascript. A naïve Javascript library that parses JSON data using eval is vulnerable to attack unless the encoded data represents an object or an array. JSON implementations in other languages conform to that same restriction to preserve interoperability and security.

jstring :: Parser TextSource

Parse a quoted JSON string.

Strict parsers

json' :: Parser ValueSource

Parse a top-level JSON value. This must be either an object or an array, per RFC 4627.

This is a strict version of json which avoids building up thunks during parsing; it performs all conversions immediately. Prefer this version if most of the JSON data needs to be accessed.

value' :: Parser ValueSource

Strict version of value. See also json'.

Helpers