Portability | portable |
---|---|
Stability | experimental |
Maintainer | Bryan O'Sullivan <bos@serpentine.com> |
Safe Haskell | Safe-Infered |
Data.Aeson.Parser.Internal
Contents
Description
Efficiently and correctly parse a JSON string. The string must be encoded as UTF-8.
Lazy parsers
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.
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.
Strict parsers
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.
Helpers
decodeWith :: Parser Value -> (Value -> Result a) -> ByteString -> Maybe aSource