fast.json

A fast JSON parser implementing RFC 7159.

The most prominent change compared to the initial revision is the allowance of all data types as root values, not just objects and arrays.

More...

Members

Enums

DataType
enum DataType

JSON data types returned by peek.

trustedSource
anonymousenum trustedSource

Validation strength of JSON parser

Functions

parseJSON
auto parseJSON(T text)

Loads a JSON string and validates the used parts. This includes a UTF-8 validation on strings.

parseJSONFile
auto parseJSONFile(char[] fname)
auto parseJSONFile(Filename fname)

Loads a file as JSON text and validates the used parts. This includes a UTF-8 validation on strings.

parseTrustedJSON
auto parseTrustedJSON(T text)

Load a JSON string that is considered 100% correct. No checks will be performed, not even if you try to read a number as a string.

parseTrustedJSONFile
Json!trustedSource.File parseTrustedJSONFile(char[] fname)
Json!trustedSource.File parseTrustedJSONFile(Filename fname)

Load a file as JSON text that is considered 100% correct. No checks will be performed, not even if you try to read a number as a string.

validateJSON
void validateJSON(T text)

Validates a JSON string.

validateJSONFile
void validateJSONFile(char[] fname)
void validateJSONFile(Filename fname)

Validates a JSON text file.

Structs

Json
struct Json(uint vl = validateUsed, bool validateUtf8 = vl > trustedSource)

This is a forward JSON parser for picking off items of interest on the go. It neither produces a node structure, nor does it produce events. Instead you can peek at the value type that lies ahead and/or directly consume a JSON value from the parser. Objects and arrays can be iterated over via foreach, while you can also directly ask for one or multiple keys of an object.

JsonMapping
struct JsonMapping

A UDA used to remap enum members or struct field names to JSON strings.

JsonParserState
struct JsonParserState

JSON parser state returned by the state property.

Detailed Description

Usage Hints

  • This parser only supports UTF-8 without BOM.
  • When a JSON object has duplicate keys, the last one in the set will determine the value of associative-array entries or struct fields.
  • BigInt and large number parsing are not implemented currently, but all integral types as well as minimal exact representations of many double values are supported.

Meta