Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Functions JsonParser.next

1
2
3
4
5

Documentation

Parses the next token from the input.

Notes

The lifetime of the token's data is directly tied to the input slice's lifetime.

Output Example

Given the following input

`json { "array": [1, true], "null": null, "subobj": { "false": false, "int": 213, "float": 1.23, "str": "string", "str2": "escaped\n", } } `

The following tokens are generated (using enum JsonParser.Token.Type)

`txt objectStart name ("array") arrayStart integer (1) boolean (true) arrayEnd

name ("null") null

name ("subobj") objectStart name ("false") boolean (false)

name ("int") integer (213)

name ("float") floating (1.23)

name ("str") string ("string", hasEscapeChars: false)

name ("str2") string ("escaped\\n", hasEscapeChars: true) objectEnd objectEnd `

Params

Throws

JsonParserError.eofunder various conditions, such as the input being empty, or an object/array being unterminated.

JsonParserError.missingCommaif there's a comma missing between values within an object/array.

JsonParserError.missingColonif there's a colon missing between an object's field's name and its value.

JsonParserError.extraCommaif the final item within an object/array has a comma after it.

JsonParserError.unexpectedCharacterunder various conditions, namely when this function cannot determine what the next token should be.

JsonParserError.invalidNumberif an integer/floating value is invalid (for various reasons).

JsonParserError.unterminatedStringif a string is unterminated.

JsonParserError.tooDeepif the depth buffer is exceeded.

JsonParserError.wrongDepthif there's an objectEndis found when an arrayEndwas expected (or vice-versa).

JsonParserError.invalidKeywordif "true", "false", or "null" was expected but something else was there (e.g. a typo like "nul").

Returns

An errorful Resultif something went wrong.