iopipe.json.parser

Members

Enums

JSONParseHint
enum JSONParseHint

Hint on how to parse this value. If the item is a Number or String, then this gives hints on how to parse it. It's a bitfield, with the first bit defining integer or float, the second bit defining

JSONToken
enum JSONToken

Tokens as parsed from the stream. This indicates what the next token is supposed to be, and doesn't necessarily validate the next item is in the correct format.

Functions

isValue
bool isValue(JSONToken token)
jsonItem
JSONItem jsonItem(Chain c, size_t pos)

Obtain one parsing item from the given iopipe. This has no notion of context, so it does not actually validate the overall structure of the JSON stream. It only confirms that the next item is a valid JSON item.

jsonTok
JSONToken jsonTok(Chain c, size_t pos)

Search for the next token in the iopipe c, ignoring white space. This does not validate data, it simply searches for the beginning of a valid JSON token. Since each token is definitive based on the first character, only the first character is looked at.

jsonTokenizer
auto jsonTokenizer(Chain c)

Wrap a text iopipe into a JSONParser struct.

parseNumber
int parseNumber(Chain c, size_t pos, JSONParseHint hint)

Parse/validate a number from the given iopipe. This is used to validate the number follows the correct grammar from the JSON spec, and also to find out how many elements in the stream are used for this number.

parseString
int parseString(Chain c, size_t pos, JSONParseHint hint)

Parse and validate a string from an iopipe. This functions serves several purposes. First, it determines how long the string actually is, so it can be properly parsed out. Second, it verifies any escapes inside the string. Third, if requested, it can replace any escapes with the actual characters in-place, so the string result can just be used. Note that this does not verify any UTF code units are valid. However, any unicode escapes using the \uXXXX sequence are validated.

Structs

JSONItem
struct JSONItem

JSON item from a specific iopipe. This is like a slice into the iopipe, but only contains offsets so as to make it easy to manipulate. No whitespace is included. Strings do not include the surrounding quotes.

JSONTokenizer
struct JSONTokenizer(Chain, bool replaceEscapes)

An object used to parse JSON items from a given iopipe chain. As the items are parsed, the structure of the JSON data is validated. Note that the data returned is simply references to within the iopipe window.

Meta

License

Boost License 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Authors

Steven Schveighoffer