aeson-1.4.2.0: Fast JSON parsing and encoding

Copyright | (c) 2011-2016 Bryan O'Sullivan (c) 2011 MailRank Inc.
License | BSD3
Maintainer | Bryan O'Sullivan <bos@serpentine.com>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Data.Aeson.Parser.Internal

Contents

- Lazy parsers
- Strict parsers
- Helpers

Description

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

Synopsis

- json :: Parser Value
- jsonEOF :: Parser Value
- value :: Parser Value
- jstring :: Parser Text
- jstring_ :: Parser Text
- scientific :: Parser Scientific
- json' :: Parser Value
- jsonEOF' :: Parser Value
- value' :: Parser Value
- decodeWith :: Parser Value -> (Value -> Result a) -> ByteString -> Maybe a
- decodeStrictWith :: Parser Value -> (Value -> Result a) -> ByteString -> Maybe a
- eitherDecodeWith :: Parser Value -> (Value -> IResult a) -> ByteString -> Either (JSONPath, String) a
- eitherDecodeStrictWith :: Parser Value -> (Value -> IResult a) -> ByteString -> Either (JSONPath, String) a

# Lazy parsers

json :: Parser Value Source #

Parse a top-level JSON value.

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.

This function is an alias for `value`. In aeson 0.8 and earlier, it parsed only object or array types, in conformance with the now-obsolete RFC 4627.

jsonEOF :: Parser Value Source #

Parse a top-level JSON value followed by optional whitespace and end-of-input. See also: `json`.

value :: Parser Value Source #

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 Text Source #

Parse a quoted JSON string.

jstring_ :: Parser Text Source #

Parse a string without a leading quote.

scientific :: Parser Scientific Source #

Parse a JSON number.

# Strict parsers

json' :: Parser Value Source #

Parse a top-level JSON value.

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.

This function is an alias for `value'`. In aeson 0.8 and earlier, it parsed only object or array types, in conformance with the now-obsolete RFC 4627.

jsonEOF' :: Parser Value Source #

Parse a top-level JSON value followed by optional whitespace and end-of-input. See also: `json'`.

value' :: Parser Value Source #

Strict version of `value`. See also `json'`.

# Helpers

decodeWith :: Parser Value -> (Value -> Result a) -> ByteString -> Maybe a Source #

decodeStrictWith :: Parser Value -> (Value -> Result a) -> ByteString -> Maybe a Source #

eitherDecodeWith :: Parser Value -> (Value -> IResult a) -> ByteString -> Either (JSONPath, String) a Source #

eitherDecodeStrictWith :: Parser Value -> (Value -> IResult a) -> ByteString -> Either (JSONPath, String) a Source #