Top level JSON type containing an entire document. A JSON document consists of exactly 1 value.
class ref JsonDoc
Default constructor building a document containing a single null.
new ref create() : JsonDoc ref^
[None](builtin-None.md) val | [String](builtin-String.md) val | [JsonArray](json-JsonArray.md) ref | [JsonObject](json-JsonObject.md) ref)
The parsed JSON structure.
Will be a None
if parse(source: String)
has not been called yet.
Generate string representation of this document.
fun box string( indent: String val = "", pretty_print: Bool val = false) : String val
Parse the given string as a JSON file, building a document. Raise error on invalid JSON in given source.
fun ref parse( source: String val) : None val ?
Give details of the error that occurred last time we attempted to parse. If parse was successful returns (0, "").
fun box parse_report() : (USize val , String val)
Parse a single JSON value of any type, which MUST be present. Raise error on invalid or missing value.
fun ref _parse_value( context: String val) : (F64 val | I64 val | Bool val | None val | String val | JsonArray ref | JsonObject ref) ?
Parse a keyword, the first letter of which has already been peeked.
fun ref _parse_keyword() : (Bool val | None val) ?
Parse a number, the leading character of which has already been peeked.
fun ref _parse_number() : (F64 val | I64 val) ?
Parse a decimal integer which must appear immediately in the source.
fun ref _parse_decimal() : (I64 val , U8 val) ?
Parse a JSON object, the leading { of which has already been peeked.
fun ref _parse_object() : JsonObject ref ?
Parse an array, the leading [ of which has already been peeked.
fun ref _parse_array() : JsonArray ref ?
Parse a string, which must be the next thing found, other than whitesapce.
fun ref _parse_string( context: String val) : String val ?
Process a string escape sequence, the leading \ of which has already been consumed.
fun ref _parse_escape() : String val ?
Process a Unicode escape sequence, the leading \u of which has already been consumed.
fun ref _parse_unicode_escape() : String val ?
Parse the hex digits of a Unicode escape sequence, the leading \u of which has already been consumed, and return the encoded character value.
fun ref _parse_unicode_digits() : U32 val ?
Dump all whitespace at the current read location in source, if any.
fun ref _dump_whitespace() : None val
Peek the next char in the source, without consuming it. If an eof_context is given then an error is thrown on eof, setting a suitable message. If eof_context is None then 0 is returned on EOF. It up to the caller to handle this appropriately.
fun ref _peek_char( eof_context: (String val | None val) = reference) : U8 val ?
Get and consume the next char in the source. If an eof_context is given then an error is thrown on eof, setting a suitable message. If eof_context is None then 0 is returned on EOF. It up to the caller to handle this appropriately.
fun ref _get_char( eof_context: (String val | None val) = reference) : U8 val ?
Get the last character peeked or got from the source as a String. For use generating error messages.
fun ref _last_char() : String val
Record an error with the given message.
fun ref _error( msg: String val) : None val
© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/json-JsonDoc