abla/json

Generated from source.

Import with import "abla/json".

Source: abla/json/entry.ab

JsonNumber (class)

class JsonNumber(
    val text: string,
    val integer: bool,
    val intValue: int,
    val intAvailable: bool
)

Holds a JSON number's original spelling and a signed integer value when intAvailable is true.

Json (class)

class Json(
    val kind: int,
    val stringValue: string,
    val intValue: int,
    val boolValue: bool,
    val keys: array<string>,
    val values: array<Json>,
    val numberValue: JsonNumber
)

An object of jsonKeyIndexMembers members or more keeps in stringValue, which it has no other use for, an index for get and has: its member count, then an open addressing table of positions + 1 into keys, probed linearly from each key's FNV-1a hash and at most half full, all as 32-bit little-endian integers. (In a string so that a node stays this size, whatever it holds.) A repeated key finds its last position, as a scan does; a count that no longer matches keys, or no index, means a scan.

JsonError (class)

class JsonError(
    val code: string,
    val message: string,
    val byteOffset: int,
    val line: int,
    val column: int
)

Holds a JSON diagnostic code, message, byte offset, line, and column.

JsonParseResult (class)

class JsonParseResult(
    val value: Json,
    val succeeded: bool,
    val error: JsonError
)

The parsed value and success flag. On failure the value is JSON null and error locates the problem.

JsonLimits (class)

class JsonLimits(
    val maximumBytes: int,
    val maximumDepth: int,
    val maximumNodes: int,
    val maximumStringBytes: int,
    val maximumObjectMembers: int,
    val rejectDuplicateKeys: bool,
    // Allowed duplicate keys as JavaScript's JSON.parse reads them: a key
    // keeps its first position and takes its last value. (Off, a parsed
    // object keeps every member in source order.)
    val mergeDuplicateKeys: bool = false
)

Bounds input bytes, depth, nodes, decoded string bytes, and object members. Use rejectDuplicateKeys to disallow repeated keys or mergeDuplicateKeys to keep the first key position with the last value when repeats are allowed.

JsonNumberGrammar (class)

class JsonNumberGrammar(
    val valid: bool,
    val integer: bool
)

Reports whether the token follows JSON number grammar and uses integer syntax.

JsonParserState (class)

class JsonParserState(
    val source: string,
    val limits: JsonLimits,
    var offset: int,
    var nodes: int,
    var errorCode: string,
    var errorMessage: string,
    var errorOffset: int
)

Tracks the input, limits, cursor, node count, and first error for a JSON parse.

JsonWriter (class)

class JsonWriter(
    val output: ByteBuffer,
    var valid: bool
)

Holds a JSON output buffer and records whether every value has encoded successfully.

JsonObjectReader (class)

class JsonObjectReader(
    val state: JsonParserState,
    val keys: array<string>,
    var first: bool,
    var done: bool,
    var expectingValue: bool,
    // The keys as a set, once an object rejecting duplicates grows long.
    var keyIndex: JsonKeyTable? = null
)

Forward-only, allocation-light object reader. Values are consumed once from the source text; callers choose whether to decode a scalar or retain a validated raw slice. This complements the tree-shaped Json API for hot protocol paths that already know their schema.

JsonArrayReader (class)

class JsonArrayReader(
    val state: JsonParserState,
    var first: bool,
    var done: bool,
    var expectingValue: bool
)

Forward-only array companion for schema-aware nested JSON. Object and array readers may share one parser state, so nested values are validated exactly once without materializing a Json tree or retaining raw substrings.

JsonEncoded (class)

class JsonEncoded(val text: string, val valid: bool)

Validated encoded fragments and streaming container builders avoid a temporary Json object graph during serialization.

JsonArrayEncoder (class)

class JsonArrayEncoder(
    val output: ByteBuffer,
    var count: int,
    var valid: bool,
    var finished: bool
)

Builds an encoded JSON array and tracks invalid input or use after finishing.

JsonObjectEncoder (class)

class JsonObjectEncoder(
    val output: ByteBuffer,
    var count: int,
    var valid: bool,
    var finished: bool
)

Builds an encoded JSON object and tracks invalid input or use after finishing.

ablaJsonFindPlainStringEnd (extern)

noescape extern:"intrinsic" fun ablaJsonFindPlainStringEnd(
    value: string,
    begin: int,
    end: int
): int

Returns the closing quote for an unescaped, valid UTF-8 JSON string, or -1 when the input needs the precise escaped-string decoder. This fuses the common path's delimiter search and validation into one raw-memory pass.

ablaJsonMatchCompactObjectField (extern)

noescape extern:"intrinsic" fun ablaJsonMatchCompactObjectField(
    value: string,
    offset: int,
    name: string,
    comma: bool
): int

Return the offset after a compact ,"name": (or first-field "name":) token, or -1 when the source needs the whitespace-aware raw fallback. One checked raw-memory pass avoids constructing a slice and then comparing that slice through the general string ABI.

ablaJsonCompactArrayNext (extern)

noescape extern:"intrinsic" fun ablaJsonCompactArrayNext(
    value: string,
    offset: int,
    first: bool
): int

Encodes a compact array transition without allocating or repeatedly crossing the checked string-index ABI. Zero selects the complete diagnostic path.

ablaJsonAvailableIntegerEnd (extern)

noescape extern:"intrinsic" fun ablaJsonAvailableIntegerEnd(
    value: string,
    begin: int
): int

Compact signed-64-bit integer decoding uses raw source bytes and returns -1 for fractions, exponents, malformed grammar, or overflow. Callers retain the full scanner as an exact diagnostic fallback for those inputs.

ablaJsonIntegerValueAt (extern)

noescape extern:"intrinsic" fun ablaJsonIntegerValueAt(
    value: string,
    begin: int,
    end: int
): int

Returns the signed integer in a byte interval already checked by ablaJsonAvailableIntegerEnd.

ablaJsonWhitespaceEnd (extern)

noescape extern:"intrinsic" fun ablaJsonWhitespaceEnd(
    value: string,
    begin: int
): int

Returns the first non-whitespace offset at or after begin, the input length at EOF, or the unchanged offset if it is out of bounds.

JsonEncoder (class)

class JsonEncoder(
    val output: ByteBuffer,
    var depth: int,
    var objectBits: int,
    var nonEmptyBits: int,
    var expectingValueBits: int,
    var rootWritten: bool,
    var valid: bool
)

Single-buffer streaming serializer. Container state is held in bitsets, so nesting does not allocate a DOM node, fragment, or context object.

jsonStandardLimits (val)

@threadShared
val jsonStandardLimits

These limits contain only immutable scalar fields and can be shared.

jsonDefaultLimits (fun)

fun jsonDefaultLimits(): JsonLimits

Returns the standard bounds and duplicate-key policy used by jsonParse.

jsonPermissiveLimits (val)

@threadShared
val jsonPermissiveLimits

What JavaScript's JSON.parse accepts: no byte, node, string or member limit, the deepest nesting jsonParse allows, and duplicate keys merged as JSON.parse merges them.

jsonNoKeys (val)

@threadShared
val jsonNoKeys: array<string>

Scalars share these: a Json never changes after it is built, so a string, number, boolean or null need not carry arrays and a number record of its own (a parse of numeric data would otherwise make several objects per value). Nothing changes them, so threads share them too.

jsonNoValues (val)

@threadShared
val jsonNoValues: array<Json>

Shared empty value array for JSON nodes that have no children.

jsonNoNumber (val)

@threadShared
val jsonNoNumber

Shared empty number record for JSON nodes that hold no number.

jsonNull (fun)

fun jsonNull(): Json

Returns the JSON null value.

jsonString (fun)

fun jsonString(value: string): Json

Wraps UTF-8 value as a JSON string. Returns JSON null for invalid UTF-8.

jsonNumber (fun)

fun jsonNumber(value: JsonNumber): Json

Builds a JSON number from value.text, recomputing integer metadata. Returns JSON null if the text is not a valid number.

jsonNumberText (fun)

fun jsonNumberText(value: string): Json

Parses value as one JSON number, preserving its exact spelling. Returns JSON null for invalid input. Integer access is available only for integer syntax within the int range.

jsonInteger (fun)

fun jsonInteger(value: int): Json

Integer formatting already produces valid JSON number text; retain the known value.

jsonBoolean (fun)

fun jsonBoolean(value: bool): Json

Returns the JSON boolean for value.

jsonArray (fun)

fun jsonArray(values: array<Json>): Json

Wraps values as a JSON array in order.

jsonRaw (fun)

fun jsonRaw(text: string): Json?

A raw node (kind 6) holds one JSON value that is already encoded: jsonStringify writes its text verbatim, as one copy, where the same value as a tree of nodes would take a node per number, string and member. For documents a service builds once and sends many times (and keeps alongside a compact form of its own). jsonParse and jsonDocument never produce one, and it reads as none of the other kinds (isNull... isObject are false, size() is 0, get() is null, asString() is ""): to read the value, jsonParse its text (jsonRawText).

jsonRaw is the checked constructor: null unless text is exactly one well-formed JSON value (valid UTF-8, any size, nesting up to what jsonParse allows), which costs one validation pass over the text. jsonRawUnchecked trusts its caller: text that is not one well-formed JSON value makes jsonStringify's output not JSON (it is not checked again), so use it only on text this program encoded itself, with jsonStringify or jsonQuote.

jsonRawUnchecked (fun)

fun jsonRawUnchecked(text: string): Json

Returns a raw JSON node that serializes text verbatim, so callers must supply one valid JSON value.

Json.isRaw (extension fun)

fun Json.isRaw(): bool

Returns true if the node holds already-encoded JSON text.

Json.rawText (extension fun)

fun Json.rawText(): string

The encoded text of a raw node, "" for any other kind.

jsonObject (fun)

fun jsonObject(keys: array<string>, values: array<Json>): Json

Pairs keys with values by position. Returns JSON null if their lengths differ or a key contains invalid UTF-8. Lookup uses the last value for a repeated key.

ablaJsonNull (fun)

fun ablaJsonNull(): Json

Compatibility constructors retained for existing $json consumers.

ablaJsonString (fun)

fun ablaJsonString(value: string): Json

Returns a JSON string, or JSON null if the input is invalid UTF-8.

ablaJsonInteger (fun)

fun ablaJsonInteger(value: int): Json

Returns a JSON number with the exact integer value.

ablaJsonNumberText (fun)

fun ablaJsonNumberText(value: string): Json

Returns a JSON number with the supplied spelling, or JSON null for invalid number text.

ablaJsonBoolean (fun)

fun ablaJsonBoolean(value: bool): Json

Returns the JSON boolean for value.

ablaJsonArray (fun)

fun ablaJsonArray(values: array<Json>): Json

Returns a JSON array containing values in order.

ablaJsonObject (fun)

fun ablaJsonObject(keys: array<string>, values: array<Json>): Json

Returns a JSON object from parallel keys and values, or JSON null for unequal lengths or a key with invalid UTF-8.

ablaJsonMergeOrder (fun)

fun ablaJsonMergeOrder(keys: array<string>): array<int>

The members a $json object with a computed key keeps (decision #154): one per key, at the position where the key first appears, each the index of the last member with that key (the later member wins, as JavaScript's JSON.parse and jsonParse's mergeDuplicateKeys read a repeated key). Linear: a map once there are more than eight members.

ablaJsonObjectMerged (fun)

fun ablaJsonObjectMerged(keys: array<string>, values: array<Json>): Json

$json's object when a key is computed: as jsonObject, with a repeated key merged (ablaJsonMergeOrder), so the output has one member per name and jsonParse accepts it; JSON null if a key is invalid UTF-8.

ablaJsonValue (fun)

fun ablaJsonValue(value: Json): Json

A $json value written as an Abla expression becomes JSON through these: the call picks the overload for the expression's type, so a value of any other type is a compile error at the value.

ablaJsonValue (fun)

fun ablaJsonValue(value: string): Json

Returns a JSON string, or JSON null if the input is invalid UTF-8.

ablaJsonValue (fun)

fun ablaJsonValue(value: string?): Json

Returns a JSON string or JSON null if the input is absent or invalid UTF-8.

ablaJsonValue (fun)

fun ablaJsonValue(value: int): Json

Returns a JSON number with the exact integer value.

ablaJsonValue (fun)

fun ablaJsonValue(value: bool): Json

Returns the JSON boolean for value.

ablaJsonValue (fun)

fun ablaJsonValue(value: JsonNumber): Json

Returns a JSON number spelled like value.text, or JSON null for invalid number text.

ablaJsonValue (fun)

fun ablaJsonValue(value: f64): Json

Returns the shortest JSON number that round-trips to value, or JSON null for NaN or infinity.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<Json>): Json

Returns a JSON array containing the input nodes in order.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<string>): Json

Returns a JSON array of the strings in order, substituting JSON null for any string with invalid UTF-8.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<string?>): Json

Returns a JSON array with null for each absent or invalid UTF-8 input.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<int>): Json

Returns a JSON array of exact integer numbers in input order.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<f64>): Json

Returns a JSON array of round-trippable numbers in input order, substituting JSON null for NaNs and infinities.

ablaJsonValue (fun)

fun ablaJsonValue(values: array<bool>): Json

Returns a JSON array of the booleans in input order.

ablaJsonKey (fun)

fun ablaJsonKey(key: string): string

A $json key written as an expression other than a string literal: only a string is accepted.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: string): void

Runtime leaves of $jsonw: typed values go straight to the caller's buffer. Use the tree writer's string encoder, without a quoted intermediate copy.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: int): void

Appends the integer's decimal representation to the JSON output buffer.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: string?): void

Appends a quoted JSON string or the literal null for absent or invalid UTF-8 input.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: bool): void

Appends the JSON literal true or false to the output buffer.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: f64): void

Appends a round-trippable JSON number, or the literal null for NaN or infinity.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: JsonNumber): void

Appends the number's original spelling if valid, or the literal null otherwise.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, value: Json): void

Explicit tree inputs are supported without building another tree.

Json.isNull (extension fun)

fun Json.isNull(): bool

Returns true when this value is JSON null.

Json.isString (extension fun)

fun Json.isString(): bool

Returns true when this value is a string.

Json.isNumber (extension fun)

fun Json.isNumber(): bool

Returns true when this value is a number.

Json.isBoolean (extension fun)

fun Json.isBoolean(): bool

Returns true when this value is a boolean.

Json.isArray (extension fun)

fun Json.isArray(): bool

Returns true when this value is an array.

Json.isObject (extension fun)

fun Json.isObject(): bool

Returns true when this value is an object.

Json.asString (extension fun)

fun Json.asString(): string

Returns the decoded string value or an empty string for other kinds.

Json.asBoolean (extension fun)

fun Json.asBoolean(): bool

Returns the boolean value, defaulting to false for other kinds.

Json.asNumber (extension fun)

fun Json.asNumber(): JsonNumber

Returns the original number spelling and integer metadata, or an empty number record for other kinds.

Json.asInt (extension fun)

fun Json.asInt(): int

Returns the integer value, or zero when intAvailable is false.

Json.intAvailable (extension fun)

fun Json.intAvailable(): bool

Returns true for a JSON number written as an integer and representable as int.

Json.get (extension fun)

fun Json.get(key: string): Json

Looks up the exact key in an object. Returns its last value when repeated or JSON null when absent. Use has to distinguish an absent key from a JSON null member.

Json.has (extension fun)

fun Json.has(key: string): bool

Returns true if the object contains the exact key, including when its value is JSON null.

Json.size (extension fun)

fun Json.size(): int

Returns the element count of an array, the member count of an object, or zero for other kinds.

Json.at (extension fun)

fun Json.at(index: int): Json

Returns the value at zero-based index in the stored values of an array or object. Panics if the index is out of bounds.

Json.getString (extension fun)

fun Json.getString(key: string): string

Returns the string at key, or an empty string when absent or of another kind.

Json.getInt (extension fun)

fun Json.getInt(key: string): int

Returns the int at key, or zero when absent or unavailable as an int.

JsonParserState.fail (extension fun)

fun JsonParserState.fail(
    code: string,
    message: string,
    offset: int
): void

Records the first parse error with its code, message, and byte offset.

jsonSkipWhitespace (fun)

fun jsonSkipWhitespace(var state: JsonParserState): void

Advances the parser cursor past consecutive JSON whitespace bytes.

jsonParseEscapedPortable (fun)

@noinline
fun jsonParseEscapedPortable(
    var state: JsonParserState,
    quoteOffset: int,
    contentBegin: int
): string

Returns the decoded JSON string and advances the cursor, recording a parse error if it encounters invalid input.

jsonParseEscapedNative (fun)

trusted fun jsonParseEscapedNative(var state: JsonParserState, begin: int): string

Decode a valid escaped string into one bounded allocation. On any unusual or invalid input leave the parser untouched and use the precise portable diagnostic path. Decoding never produces more bytes than the source span.

jsonParseStringFallback (fun)

@noinline
fun jsonParseStringFallback(
    var state: JsonParserState,
    quoteOffset: int,
    contentBegin: int
): string

Returns a decoded JSON string starting at the given quote, using the portable decoder to report errors the fast decoder cannot handle.

JsonKeyTable (class)

class JsonKeyTable(
    val names: array<string>,
    val hashes: array<int>,
    var slots: array<int>,
    var mask: int
)

The keys of an object rejecting duplicates, once it grows long: an open addressing table of positions + 1 into names, probed linearly from each name's FNV-1a hash and kept at most half full.

JsonKeyTable.repeatsOrAdd (extension fun)

fun JsonKeyTable.repeatsOrAdd(key: string): bool

Whether key is in the table; adds it when it is not.

JsonKeyTable.positionOrAdd (extension fun)

fun JsonKeyTable.positionOrAdd(key: string): int

key's position in the table, or -1 when it is new; adds it then.

jsonKeyIndexTextNative (fun)

trusted fun jsonKeyIndexTextNative(count: int, slots: array<int>): string

Encodes the member count and hash table slots as unsigned 32-bit little-endian words.

jsonParse (fun)

fun jsonParse(
    source: string,
    limits: JsonLimits = jsonDefaultLimits()
): JsonParseResult

Parses one JSON value from UTF-8 source using limits. Invalid syntax, trailing input, invalid UTF-8, and limit violations return succeeded = false with JSON null and a diagnostic location.

jsonValidate (fun)

fun jsonValidate(
    source: string,
    limits: JsonLimits = jsonDefaultLimits()
): JsonParseResult

Whether source is one JSON value jsonParse accepts under limits, without building it: the same result as jsonParse (succeeded, and the error's code, message, offset, line and column), with a null value. It checks what jsonParse checks, in the same order, and allocates only for strings with escapes and for object keys it must compare (duplicates rejected or merged).

JsonDocument (class)

class JsonDocument(
    val source: string,
    val tape: array<int>,
    val limits: JsonLimits
)

A parsed document kept as its source and a tape: four ints per value, in source order, so a large document is a few allocations and nothing the collector traces value by value. Each value is [kind | flag | count << 8, begin, end, next]: Json's kinds (0 null, 1 string, 2 number, 3 boolean, 4 array, 5 object); the flag (16) marks a string with escapes, true, an integer number, or an object whose repeated keys merged; count is an array's elements or the members jsonParse's object would hold; [begin, end) is the value's source bytes (a string's with its quotes); next is the tape index after it. An object's members are a key (a string) followed by its value, every one as written.

JsonNode (class)

class JsonNode(
    val document: JsonDocument,
    val index: int
)

A value of a document: its tape index, or -1 for a missing one (which reads as null).

JsonDocumentResult (class)

class JsonDocumentResult(
    val document: JsonDocument,
    val succeeded: bool,
    val error: JsonError
)

Holds a tape-backed JSON document and success flag, with a diagnostic describing a failed parse.

jsonDocument (fun)

fun jsonDocument(
    source: string,
    limits: JsonLimits = jsonDefaultLimits()
): JsonDocumentResult

source parsed into a document: the same succeeded and error jsonParse gives under limits, and on success a document whose nodes read as jsonParse's tree does (toJson() builds that tree for any node).

JsonDocument.root (extension fun)

fun JsonDocument.root(): JsonNode

Returns the document's root node, or a missing node when there is no parsed root.

JsonNode.kind (extension fun)

fun JsonNode.kind(): int

Returns the value kind as an integer from 0 (null) through 5 (object). Missing nodes use kind 0, so use exists to distinguish them.

JsonNode.isNull (extension fun)

fun JsonNode.isNull(): bool

Returns true when this node represents JSON null or is missing.

JsonNode.isString (extension fun)

fun JsonNode.isString(): bool

Returns true when this node represents a string.

JsonNode.isNumber (extension fun)

fun JsonNode.isNumber(): bool

Returns true when this node represents a number.

JsonNode.isBoolean (extension fun)

fun JsonNode.isBoolean(): bool

Returns true when this node represents a boolean.

JsonNode.isArray (extension fun)

fun JsonNode.isArray(): bool

Returns true when this node represents an array.

JsonNode.isObject (extension fun)

fun JsonNode.isObject(): bool

Returns true when this node represents an object.

JsonNode.exists (extension fun)

fun JsonNode.exists(): bool

Whether the node is a value of the document (not a missing member or element).

JsonNode.size (extension fun)

fun JsonNode.size(): int

An array's elements or an object's members (as jsonParse's object holds them: repeated keys counted once when they merge); 0 for anything else.

JsonNode.raw (extension fun)

fun JsonNode.raw(): string

The value's source text, exactly as written (a string with its quotes); "" for a missing node.

JsonNode.asString (extension fun)

fun JsonNode.asString(): string

Returns the decoded string or an empty string for a missing node or another kind.

JsonNode.asBoolean (extension fun)

fun JsonNode.asBoolean(): bool

Returns the boolean, or false for a missing node or another kind.

JsonNode.asNumber (extension fun)

fun JsonNode.asNumber(): JsonNumber

As Json's asNumber: the number's text and integer value (an empty number for anything else).

JsonNode.intAvailable (extension fun)

fun JsonNode.intAvailable(): bool

Returns true for a number written as an integer and representable as int.

JsonNode.asInt (extension fun)

fun JsonNode.asInt(): int

Returns the node's integer value or zero when intAvailable is false.

JsonNode.asF64 (extension fun)

fun JsonNode.asF64(): f64

A number as the nearest f64 (as a reader's readNumber); 0.0 otherwise.

JsonNode.utf16Length (extension fun)

fun JsonNode.utf16Length(): int

A string's length in UTF-16 code units, as JavaScript counts it; 0 otherwise.

JsonNode.at (extension fun)

fun JsonNode.at(position: int): JsonNode

An array's element or an object's member value at position (as Json's at), or a missing node.

JsonNode.keyAt (extension fun)

fun JsonNode.keyAt(position: int): string

An object's key at position (as Json's keys), or "".

JsonNode.get (extension fun)

fun JsonNode.get(key: string): JsonNode

The value of an object's last member keyed key (as Json's get), or a missing node.

JsonNode.has (extension fun)

fun JsonNode.has(key: string): bool

Returns true if the node is an object with member key, including a member with a null value.

JsonNode.getString (extension fun)

fun JsonNode.getString(key: string): string

Returns the decoded string at key, or an empty string when absent or of another kind.

JsonNode.getInt (extension fun)

fun JsonNode.getInt(key: string): int

Returns the int at key, or zero when absent or unavailable as an int.

JsonCursor (class)

class JsonCursor(
    val document: JsonDocument,
    // The array or object (its tape index), -1 for an empty cursor.
    val container: int,
    // The current element's or member value's tape index (-1 before the first
    // and after the last), and a member's key's.
    var index: int,
    var keyIndex: int,
    // Members or elements stepped to so far, and the tape index to visit next.
    var position: int,
    var following: int
)

A forward cursor over an array's elements or an object's members, which reads the current one in place: stepping and reading scalars allocate nothing (only node(), key() and nested cursors do). An object's members come as jsonParse's object holds them: with merged repeated keys, each key once, at its first position, with its last value.

JsonNode.elements (extension fun)

fun JsonNode.elements(): JsonCursor

Returns a cursor over array elements, or an empty cursor for another kind. Call next before reading.

JsonNode.members (extension fun)

fun JsonNode.members(): JsonCursor

Returns a cursor over object members, or an empty cursor for another kind. Call next before reading.

JsonCursor.next (extension fun)

fun JsonCursor.next(): bool

Steps to the next element or member: false (and nothing current) past the last.

JsonCursor.node (extension fun)

fun JsonCursor.node(): JsonNode

Returns the current value as a node. Before the first successful next and after exhaustion, returns a missing node.

JsonCursor.kind (extension fun)

fun JsonCursor.kind(): int

Returns the current value's kind. Kind 0 represents null or no current value.

JsonCursor.size (extension fun)

fun JsonCursor.size(): int

Returns the element or member count of the current array or object, or zero for another kind or no current value.

JsonCursor.raw (extension fun)

fun JsonCursor.raw(): string

Returns the current value's original JSON spelling, or an empty string when there is no current value.

JsonCursor.asString (extension fun)

fun JsonCursor.asString(): string

Returns the current string decoded, or an empty string if it is missing or another kind.

JsonCursor.asBoolean (extension fun)

fun JsonCursor.asBoolean(): bool

Returns the current boolean, or false if it is missing or another kind.

JsonCursor.asNumber (extension fun)

fun JsonCursor.asNumber(): JsonNumber

Returns the current number's original spelling and integer metadata, or an empty number record for another kind or no current value.

JsonCursor.asInt (extension fun)

fun JsonCursor.asInt(): int

Returns the current int, or zero when intAvailable is false.

JsonCursor.asF64 (extension fun)

fun JsonCursor.asF64(): f64

Returns the current number rounded to f64, or zero if the cursor is not on a number.

JsonCursor.intAvailable (extension fun)

fun JsonCursor.intAvailable(): bool

Returns true when the current value is a JSON integer representable as int.

JsonCursor.utf16Length (extension fun)

fun JsonCursor.utf16Length(): int

Returns the current string's length in UTF-16 code units, or zero if the cursor is not on a string.

JsonCursor.elements (extension fun)

fun JsonCursor.elements(): JsonCursor

Returns a cursor over the current array's elements, or an empty cursor for a value of another kind.

JsonCursor.members (extension fun)

fun JsonCursor.members(): JsonCursor

Returns a cursor over the current object's members, or an empty cursor for a value of another kind.

JsonCursor.key (extension fun)

fun JsonCursor.key(): string

The current member's key ("" for an element).

JsonCursor.keyIs (extension fun)

fun JsonCursor.keyIs(name: string): bool

Whether the current member's key is name, compared in place.

jsonJsKeyOrder (fun)

fun jsonJsKeyOrder(value: Json): Json

value with every object's members in the order JavaScript gives them (array indexes first, ascending, then the other keys in their order), as JSON.stringify(JSON.parse(text)) writes them.

JsonEdits (class)

class JsonEdits(
    val document: JsonDocument,
    val targets: array<int>,
    val keys: array<string>,
    val deletes: array<bool>,
    val values: array<Json>,
    // Per object's tape index, its edits' positions, in order.
    val byObject: Map<int, array<int>>,
    // Per object written from a member list (edited, or with merged keys).
    val prepared: Map<int, JsonEmitMembers>
)

Edits to a document's objects, written out with the rest of the document in one pass by emit(). An edit names an object of the document (a JsonNode) and a key; edits apply in the order they were made, to the object's members as jsonParse holds them: set replaces the value of the last member with that key, or adds the member at the end; delete removes every member with that key. Edits naming anything but an object of this document are ignored.

JsonEmitMembers (class)

class JsonEmitMembers(
    val keys: array<string>,
    val tapeValues: array<int>,
    val jsonValues: array<Json>
)

An object's members as emit writes them: each a key and either a tape index (value from the document) or, at -1, a Json from an edit.

jsonEmitPlaceholder (val)

@threadShared
val jsonEmitPlaceholder

Shared JSON null placeholder for edit records without a replacement value.

JsonDocument.edits (extension fun)

fun JsonDocument.edits(): JsonEdits

Returns an empty edit collection tied to this document.

JsonEdits.set (extension fun)

fun JsonEdits.set(target: JsonNode, key: string, value: Json): void

Queues replacement of the last member with key or appends it if absent, ignoring targets outside this document or of another kind.

JsonEdits.delete (extension fun)

fun JsonEdits.delete(target: JsonNode, key: string): void

Queues removal of all members with key, ignoring targets outside this document or of another kind.

JsonEdits.toJson (extension fun)

fun JsonEdits.toJson(jsKeyOrder: bool = false): Json

The edited document as a tree: what jsonParse gives, with the edits applied (with every object's keys in JavaScript's order, if asked).

JsonDocument.emit (extension fun)

fun JsonDocument.emit(jsKeyOrder: bool = false): string

The document as jsonStringify writes jsonParse's tree (in JavaScript's key order, if asked: as JSON.stringify(JSON.parse(source)) writes it).

JsonEdits.emit (extension fun)

fun JsonEdits.emit(jsKeyOrder: bool = false): string

The edited document as jsonStringify writes it (jsonStringify(toJson())), in one pass over the tape: numbers as written, strings as jsonStringify writes them, edited objects (and objects whose repeated keys merged) from their members; "null" when an edit's value can't be written. With jsKeyOrder, every object's keys come in JavaScript's order (array indexes first, ascending), as JSON.stringify writes an object JSON.parse made and the edits changed.

JsonNode.toJson (extension fun)

fun JsonNode.toJson(jsKeyOrder: bool = false): Json

The node as jsonParse's tree: equal kind by kind, member by member, to what jsonParse built for these bytes under the document's limits (null for a missing node).

jsonScanNumber (fun)

fun jsonScanNumber(var state: JsonParserState): void

Advances over one JSON number and records an error when the token fails number grammar.

jsonObjectReader (fun)

fun jsonObjectReader(
    source: string,
    limits: JsonLimits = jsonDefaultLimits()
): JsonObjectReader

Starts a forward reader for a JSON object at the start of source with limits. Invalid limits, input size, or a missing opening brace put the reader into an error state. Use finish to check successful consumption.

JsonObjectReader.next (extension fun)

fun JsonObjectReader.next(): string

Advance to the next member and return its decoded key. An empty result is unambiguous when done is inspected; empty JSON object keys remain valid.

JsonObjectReader.nextExpected (extension fun)

fun JsonObjectReader.nextExpected(name: string): bool

Order-sensitive lookup is the fast path for canonical protocols. It still parses and unescapes the actual key, but never rewinds or scans for another member when the schema order is known.

JsonObjectReader.nextExpectedRaw (extension fun)

@inline
fun JsonObjectReader.nextExpectedRaw(name: string): bool

Fastest canonical-schema lookup: compare an unescaped key directly in the source buffer. Producers using this contract emit ordinary UTF-8 field names; escaped spellings of the same key are deliberately rejected.

jsonObjectReaderExpectedRawFallback (fun)

@noinline
fun jsonObjectReaderExpectedRawFallback(
    var reader: JsonObjectReader, name: string, originalOffset: int
): bool

Keep diagnostics outside the common constant-schema comparison, allowing LLVM to specialize short literal field names without duplicating fallback code.

jsonObjectReaderExpectedRawDiagnostic (fun)

@noinline
fun jsonObjectReaderExpectedRawDiagnostic(
    var reader: JsonObjectReader, name: string, originalOffset: int
): bool

Malformed fields and keys with whitespace before the colon retain the precise original scanner without growing the whitespace fast-path frame.

JsonObjectReader.readString (extension fun)

fun JsonObjectReader.readString(): string

Returns the decoded string at the current member and records an error for a missing or invalid value.

jsonReadIntegerFallback (fun)

@noinline
fun jsonReadIntegerFallback(var state: JsonParserState, begin: int): int

Malformed or unavailable integers use the full diagnostic scanner. Keep its temporary strings and grammar object out of every successful read's GC-root frame.

JsonObjectReader.readInteger (extension fun)

trusted fun JsonObjectReader.readInteger(): int

Keep the native scans local: a shared helper added overhead even with LLVM inlining. Both readers clear expectingValue only after parsing/diagnostics.

JsonObjectReader.readBoolean (extension fun)

fun JsonObjectReader.readBoolean(): bool

Consumes the current member as a boolean and returns it, or records an error and returns false for a missing or invalid value.

JsonObjectReader.readNumber (extension fun)

fun JsonObjectReader.readNumber(): f64

Any JSON number (fraction and exponent included) as the nearest f64.

JsonObjectReader.peek (extension fun)

fun JsonObjectReader.peek(): int

The current value's kind without consuming it, as Json.kind numbers kinds (0 null, 1 string, 2 number, 3 boolean, 4 array, 5 object); -1 when there is no current value or the reader has failed.

JsonObjectReader.readNull (extension fun)

fun JsonObjectReader.readNull(): bool

Consumes a null value and returns true; false leaves the value unread.

JsonObjectReader.readObject (extension fun)

fun JsonObjectReader.readObject(): JsonObjectReader

Returns a nested reader sharing the parser state, which records an error if the current member is missing or is not an object.

JsonObjectReader.readArray (extension fun)

fun JsonObjectReader.readArray(): JsonArrayReader

Returns a nested reader sharing the parser state, which records an error if the current member is missing or is not an array.

JsonObjectReader.readRaw (extension fun)

fun JsonObjectReader.readRaw(): string

Returns the current member's validated JSON text, or records an error and returns an empty string if the value is invalid or absent.

JsonObjectReader.readStringPairsRaw (extension fun)

fun JsonObjectReader.readStringPairsRaw(): string

Validate an array of two-string tuples and retain its original encoded slice. This common protocol shape (notably HTTP headers) avoids a dynamic tree and avoids pulling the generic recursive scanner into small binaries.

JsonObjectReader.skip (extension fun)

fun JsonObjectReader.skip(): void

Validates and consumes the current member without returning it, recording a parse error if the value cannot be read.

JsonObjectReader.finish (extension fun)

fun JsonObjectReader.finish(): bool

Returns true if the object ended cleanly at the end of the input and every member was consumed.

JsonObjectReader.finishNested (extension fun)

fun JsonObjectReader.finishNested(): bool

Returns true if the nested object ended cleanly and every member was consumed, leaving the cursor after its closing brace.

jsonArrayReader (fun)

fun jsonArrayReader(
    source: string,
    limits: JsonLimits = jsonDefaultLimits()
): JsonArrayReader

Returns a streaming reader for a top-level array, with a parser error for invalid limits or a missing opening bracket.

JsonArrayReader.next (extension fun)

fun JsonArrayReader.next(): bool

Returns true when another array value is ready, or false at the closing bracket or after a parse error.

JsonArrayReader.readString (extension fun)

fun JsonArrayReader.readString(): string

Returns the decoded string at the current element and records an error for a missing or invalid value.

JsonArrayReader.readInteger (extension fun)

trusted fun JsonArrayReader.readInteger(): int

Consumes the current element as an int, or records a parse error and returns zero for a missing value, other number syntax, or overflow.

JsonArrayReader.readBoolean (extension fun)

fun JsonArrayReader.readBoolean(): bool

Consumes the current element as a boolean, or records an error and returns false for a missing or invalid value.

JsonArrayReader.readNumber (extension fun)

fun JsonArrayReader.readNumber(): f64

Any JSON number (fraction and exponent included) as the nearest f64.

JsonArrayReader.peek (extension fun)

fun JsonArrayReader.peek(): int

The current value's kind without consuming it, as Json.kind numbers kinds (0 null, 1 string, 2 number, 3 boolean, 4 array, 5 object); -1 when there is no current value or the reader has failed.

JsonArrayReader.readNull (extension fun)

fun JsonArrayReader.readNull(): bool

Consumes a null value and returns true; false leaves the value unread.

JsonArrayReader.readObject (extension fun)

fun JsonArrayReader.readObject(): JsonObjectReader

Returns a nested reader sharing the parser state, which records an error if the current element is missing or is not an object.

JsonArrayReader.readArray (extension fun)

fun JsonArrayReader.readArray(): JsonArrayReader

Returns a nested reader sharing the parser state, which records an error if the current element is missing or is not an array.

JsonArrayReader.readRaw (extension fun)

fun JsonArrayReader.readRaw(): string

The current element's encoded text, validated but not decoded, as the input spells it (from its first byte to its last; the whitespace around it is skipped). "" once the reader has failed.

JsonArrayReader.skip (extension fun)

fun JsonArrayReader.skip(): void

Validates and consumes the current element without returning it, recording a parse error if the value cannot be read.

JsonArrayReader.finish (extension fun)

fun JsonArrayReader.finish(): bool

Returns true if the array ended cleanly at the end of the input and every element was consumed.

JsonArrayReader.finishNested (extension fun)

fun JsonArrayReader.finishNested(): bool

Returns true if the nested array ended cleanly and every element was consumed, leaving the cursor after its closing bracket.

ablaJsonStringIsPlain (extern)

noescape extern:"intrinsic" fun ablaJsonStringIsPlain(
    value: string
): bool

One raw pass handles the common JSON-string case. Keeping the source data pointer and length outside the loop avoids re-entering generic string indexing for every byte while preserving the full UTF-8 boundary checks.

jsonAppendStringPortable (fun)

@noinline
fun jsonAppendStringPortable(var output: ByteBuffer, value: string): bool

Appends a quoted JSON string and returns true, or returns false if invalid UTF-8 interrupts the write.

jsonAppendEscapedNative (fun)

@noinline
trusted fun jsonAppendEscapedNative(var output: ByteBuffer, value: string): void

Valid UTF-8 only: size once, then write the escaped bytes into one reserved span. The portable writer is the evaluator's; it is not in a runtime build.

jsonEscapedSize (fun)

trusted fun jsonEscapedSize(value: string): int

The bytes value takes as a quoted, escaped JSON string.

jsonAppendPlainNative (fun)

trusted fun jsonAppendPlainNative(var output: ByteBuffer, value: string): void

Short plain strings need one reservation instead of three token appends. Large strings retain the chunk path, avoiding an extra contents copy.

jsonQuote (fun)

fun jsonQuote(value: string): string

Encode one UTF-8 string as a complete JSON string literal without building a dynamic Json tree. Protocol adapters can use this for streaming object envelopes while retaining the same escaping and validation rules as jsonStringify.

jsonAppendQuoted (fun)

fun jsonAppendQuoted(var out: ByteBuffer, value: string): void

value as a JSON string appended to out: the same bytes as out.appendText(jsonQuote(value)), without the quoted copy of a plain string.

jsonEncodeString (fun)

fun jsonEncodeString(value: string): JsonEncoded

Returns a quoted JSON string fragment with a validity flag that is false for invalid UTF-8.

jsonEncodeObjectKey (fun)

fun jsonEncodeObjectKey(value: string): JsonEncoded

Static schemas can precompute the complete quoted-key-and-colon token. This preserves ordinary JSON escaping while requiring one output append instead of separate key and colon fragments at runtime.

jsonEncodeBoolean (fun)

fun jsonEncodeBoolean(value: bool): JsonEncoded

Returns the valid JSON encoded fragment true or false.

jsonEncoder (fun)

fun jsonEncoder(): JsonEncoder

Creates an empty writer for one JSON value. Use finish to obtain the text or the invalid-output sentinel.

JsonEncoder.prepareValue (extension fun)

fun JsonEncoder.prepareValue(): void

Prepares the next value slot, inserting an array separator when needed and invalidating a second root or a member without a key.

JsonEncoder.beginObject (extension fun)

fun JsonEncoder.beginObject(): void

Starts an object at the current value position. Invalid placement or nesting beyond 63 levels invalidates the encoder.

JsonEncoder.beginArray (extension fun)

fun JsonEncoder.beginArray(): void

Starts an array at the current value position. Invalid placement or nesting beyond 63 levels invalidates the encoder.

JsonEncoder.key (extension fun)

fun JsonEncoder.key(name: string): void

Writes object member name and expects its value next. Invalid UTF-8, a key outside an object, or a previous key missing its value invalidates the encoder.

JsonEncoder.encodedKey (extension fun)

fun JsonEncoder.encodedKey(key: JsonEncoded): void

Static protocol schemas may quote and validate a key at compile time with

jsonEncodeString, then append that trusted fragment without rescanning it

for every encoded object.

JsonEncoder.encodedObjectKey (extension fun)

fun JsonEncoder.encodedObjectKey(key: JsonEncoded): void

Writes a pre-encoded key and colon, invalidating the encoder if the key is invalid or there is no available object member slot.

JsonEncoder.string (extension fun)

fun JsonEncoder.string(value: string): void

Writes UTF-8 value as a JSON string. Invalid UTF-8 or invalid placement invalidates the encoder.

JsonEncoder.integer (extension fun)

fun JsonEncoder.integer(value: int): void

Writes value as a decimal JSON integer. Invalid placement invalidates the encoder.

JsonEncoder.number (extension fun)

fun JsonEncoder.number(value: f64): void

A number the way JSON.stringify writes it: f64Text, and null for NaN and the infinities, which JSON cannot hold.

JsonEncoder.boolean (extension fun)

fun JsonEncoder.boolean(value: bool): void

Writes value as a JSON boolean. Invalid placement invalidates the encoder.

JsonEncoder.nullValue (extension fun)

fun JsonEncoder.nullValue(): void

Writes JSON null at the current value position, invalidating the encoder if there is no available slot.

JsonEncoder.endObject (extension fun)

fun JsonEncoder.endObject(): void

Closes the current object. An unmatched close or a member still missing its value invalidates the encoder.

JsonEncoder.endArray (extension fun)

fun JsonEncoder.endArray(): void

Closes the current array. An unmatched close invalidates the encoder.

JsonEncoder.finish (extension fun)

fun JsonEncoder.finish(): string

Returns the encoded text when one root value is complete. Returns the text null if nothing was written, a container remains open, or the encoder is invalid.

jsonArrayEncoder (fun)

fun jsonArrayEncoder(): JsonArrayEncoder

Returns a fresh encoder for one JSON array.

JsonArrayEncoder.add (extension fun)

fun JsonArrayEncoder.add(value: JsonEncoded): void

Appends an encoded element, marking the encoder invalid if the value is invalid or the array has already finished.

JsonArrayEncoder.finish (extension fun)

fun JsonArrayEncoder.finish(): JsonEncoded

Closes the array and returns its encoded text, or an invalid null fragment after a prior error or a repeated finish.

jsonObjectEncoder (fun)

fun jsonObjectEncoder(): JsonObjectEncoder

Returns a fresh encoder for one JSON object.

JsonObjectEncoder.put (extension fun)

fun JsonObjectEncoder.put(name: string, value: JsonEncoded): void

Appends one encoded member, marking the encoder invalid for invalid UTF-8 in the name, an invalid value, or a finished object.

JsonObjectEncoder.finish (extension fun)

fun JsonObjectEncoder.finish(): JsonEncoded

Closes the object and returns its encoded text, or an invalid null fragment after a prior error or a repeated finish.

jsonStringify (fun)

fun jsonStringify(value: Json): string

Serializes value to compact JSON text. If a node cannot be encoded, returns the text null. Raw nodes are emitted verbatim.

jsonStringifyPretty (fun)

fun jsonStringifyPretty(value: Json, sortKeys: bool = false, maxDepth: int = 128): JsonEncoded

Serializes a JSON tree with two-space indentation and no terminal newline. Sorts object keys lexically when requested. Returns an invalid fragment for invalid nodes, raw text nodes, or a value beyond maxDepth (the root is depth zero).

ablaJsonSyntaxCall (compile.fun)

compile fun ablaJsonSyntaxCall(
    name: string,
    value: SyntaxExpression
): SyntaxExpression

Builds a single-argument call. Static stringification can return a literal.

ablaJsonParseValue (compile.fun)

compile fun ablaJsonParseValue(cursor: ParserCursor): SyntaxExpression

A value is a JSON object or array when it starts with { or [; anything else is an Abla expression. A number literal on its own keeps its source text (so 9223372036854775808 and 1.5e-2 stay exact), string, Boolean and null literals map directly, and any other expression is converted by its type through ablaJsonValue. Unlike JSON, an object or array may end in a comma.

ablaJsonParseForm (compile.fun)

compile fun ablaJsonParseForm(cursor: ParserCursor, streamed: bool): SyntaxExpression

Returns syntax for a JSON value, using the streaming form for containers when requested and reporting malformed input through the cursor.

ablaJsonNumberLiteral (compile.fun)

compile fun ablaJsonNumberLiteral(kind: string): bool

Returns true if the syntax kind is an integer or float literal.

ablaJsonExpect (compile.fun)

compile fun ablaJsonExpect(
    cursor: ParserCursor,
    token: string,
    message: string
)

Consumes token or records the supplied parser error if the next token does not match.

ablaJsonParseArray (compile.fun)

compile fun ablaJsonParseArray(cursor: ParserCursor, streamed: bool = false): SyntaxExpression

Returns syntax for a JSON array and reports malformed elements or delimiters through the cursor.

ablaJsonParseObject (compile.fun)

compile fun ablaJsonParseObject(cursor: ParserCursor, streamed: bool = false): SyntaxExpression

Returns syntax for a JSON object with optional guarded members and reports malformed fields or delimiters through the cursor.

ablaJsonParseStringifiedValue (compile.fun)

compile fun ablaJsonParseStringifiedValue(
    cursor: ParserCursor
): SyntaxExpression

Returns compact JSON text, folding shallow static literals after a successful parse.

JsonLiteralObject (class)

class JsonLiteralObject(val keys: array<string>, val values: array<Json>)

The tree form allocates this builder only for objects with guarded members. Streaming lowers the same parsed members directly, without this runtime data.

ablaJsonLiteralObject (fun)

fun ablaJsonLiteralObject(): JsonLiteralObject

Returns a builder with no members for a guarded JSON object.

ablaJsonLiteralMember (fun)

fun ablaJsonLiteralMember(var object: JsonLiteralObject, key: string, value: Json): void

Appends one key and its value to the guarded object builder.

ablaJsonLiteralFinish (fun)

fun ablaJsonLiteralFinish(object: JsonLiteralObject): Json

Returns the completed JSON object or JSON null if a key is invalid UTF-8 or the key and value counts differ.

ablaJsonLiteralFinishMerged (fun)

fun ablaJsonLiteralFinishMerged(object: JsonLiteralObject): Json

Returns the completed JSON object of a guarded object with a computed key, a repeated key merged as ablaJsonObjectMerged does, or JSON null if a key is invalid UTF-8.

JsonObjectSyntaxKeys (class)

compile class JsonObjectSyntaxKeys(
    val statements: array<SyntaxExpression>,
    val guards: array<string>,
    val keys: array<string>,
    var valid: SyntaxExpression,
    var nextKey: int,
    // True when a computed or invalid literal key requires generated validity checks.
    var checked: bool = false
)

Holds the generated guard and key expressions and the condition that all selected keys are valid.

ablaJsonGuardedKeys (compile.fun)

compile fun ablaJsonGuardedKeys(expression: SyntaxExpression, prefix: string, first: int): JsonObjectSyntaxKeys

Evaluate guards and selected computed keys once, before any values. A false guard skips its key and value; an invalid selected key makes the object null.

ablaJsonGuardedTree (compile.fun)

compile fun ablaJsonGuardedTree(expression: SyntaxExpression, prefix: string): SyntaxExpression

Returns syntax that builds an object from selected members or yields JSON null if a selected key is invalid.

JsonWriteSyntaxPlan (class)

compile class JsonWriteSyntaxPlan(
    var sink: SyntaxExpression,
    val prefix: string,
    val statements: array<SyntaxExpression>,
    var pending: string,
    var nextKey: int,
    // The selected buffer append method, or -1 when the typed helper is needed.
    var textTarget: int = -1
)

A compile-time plan, never a runtime writer or Json tree. Parsing is shared with $json: only the constructor syntax produced by that parser is lowered.

ablaJsonWriteTextCall (compile.fun)

compile fun ablaJsonWriteTextCall(var plan: JsonWriteSyntaxPlan, text: string): SyntaxExpression

Returns syntax that appends a static fragment directly to the buffer, using the typed helper when its method cannot be resolved. An incompatible sink is diagnosed when the generated expression is type checked.

ablaJsonWriteFlush (compile.fun)

compile fun ablaJsonWriteFlush(var plan: JsonWriteSyntaxPlan): void

Coalesces pending literal bytes into one append statement and clears the pending text.

ablaJsonWriteText (fun)

fun ablaJsonWriteText(var out: ByteBuffer, text: string): void

Public because generated calls resolve in the importing module.

ablaJsonWriteLeaf (compile.fun)

compile fun ablaJsonWriteLeaf(
    var plan: JsonWriteSyntaxPlan,
    value: SyntaxExpression
): void

Flushes pending text and emits a typed buffer-write call for a dynamic JSON value.

ablaJsonWriteLower (compile.fun)

compile fun ablaJsonWriteLower(
    var plan: JsonWriteSyntaxPlan,
    expression: SyntaxExpression
): void

Lowers the JSON constructor syntax produced by the literal parser into buffer-write statements.

ablaJsonWriteObject (compile.fun)

compile fun ablaJsonWriteObject(
    var plan: JsonWriteSyntaxPlan,
    expression: SyntaxExpression
): void

Lowers one object into buffer writes, evaluating computed keys once and emitting JSON null if any key is invalid UTF-8.

ablaJsonWriteKeyValid (fun)

fun ablaJsonWriteKeyValid(key: string): bool

Returns true if the supplied object key contains valid UTF-8.

JsonWrittenMembers (class)

class JsonWrittenMembers(val keys: array<string>, val texts: array<string>)

$jsonw objects with a computed key (decision #154): each member's value is written to a buffer of its own, in source order, and the members are merged as the tree form merges them (ablaJsonMergeOrder) before the object is written. Objects without a computed key are written directly.

ablaJsonWrittenMembers (fun)

fun ablaJsonWrittenMembers(): JsonWrittenMembers

Returns an empty member list for a $jsonw object with a computed key.

ablaJsonWrittenValue (fun)

fun ablaJsonWrittenValue(): ByteBuffer

Returns a buffer for one member's value of a $jsonw object with a computed key.

ablaJsonWrittenMember (fun)

fun ablaJsonWrittenMember(var members: JsonWrittenMembers, key: string, var value: ByteBuffer): void

Records one member: its key and the JSON text written for its value.

ablaJsonWriteMerged (fun)

fun ablaJsonWriteMerged(var out: ByteBuffer, members: JsonWrittenMembers): void

Writes the recorded members as one object, a repeated key merged (the later member wins, at the first one's position).

ablaJsonWriteMergedObject (compile.fun)

compile fun ablaJsonWriteMergedObject(var plan: JsonWriteSyntaxPlan, keys: array<SyntaxExpression>, values: SyntaxExpression,
    guards: array<string>, valid: SyntaxExpression): void

Adds syntax that writes an object with a computed key through JsonWrittenMembers: keys are the key expressions (literals or the bound locals), guards the guard locals ("" for none); null is written instead when valid is false.

ablaJsonWriteGuardedObject (compile.fun)

compile fun ablaJsonWriteGuardedObject(var plan: JsonWriteSyntaxPlan, expression: SyntaxExpression): void

Adds syntax to stream the selected object members or write null if a selected key is invalid.

ablaJsonParseWrittenValue (compile.fun)

compile fun ablaJsonParseWrittenValue(cursor: ParserCursor): SyntaxExpression

$jsonw(buffer) value appends one complete value and returns that buffer. The sink is evaluated once. Static tokens collapse into one append per run; dynamic leaves use ordinary type-checked calls and create no Json nodes.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<string>): void

Appends a JSON array of strings, encoding invalid UTF-8 elements as null.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<string?>): void

Appends a JSON array with null for each absent or invalid UTF-8 input.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<int>): void

Appends a JSON array of decimal integers in input order.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<bool>): void

Appends a JSON array of boolean literals in input order.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<f64>): void

Appends a JSON array of round-trippable numbers, encoding NaN and infinity as null.

ablaJsonWriteValue (fun)

fun ablaJsonWriteValue(var out: ByteBuffer, values: array<Json>): void

Appends a JSON array of the supplied nodes in input order.

ablaJsonWriteStablePlace (compile.fun)

compile fun ablaJsonWriteStablePlace(place: SyntaxExpression): bool

Rebuild the stable place for each use; no mutable borrow is saved as a val.

ablaJsonWriteSink (compile.fun)

compile fun ablaJsonWriteSink(place: SyntaxExpression): SyntaxExpression

Returns syntax for reusing a stable buffer place without reevaluating its captured indices.

ablaJsonWritePlace (compile.fun)

compile fun ablaJsonWritePlace(
    var plan: JsonWriteSyntaxPlan,
    place: SyntaxExpression
): SyntaxExpression

Returns a stable buffer place and stages locals so its index expressions are evaluated once.

JsonDecoded (interface)

sealed interface JsonDecoded

What jsonDecode answers: the value, or why there is none. The cases are JsonParsed, JsonMalformed and JsonLimitExceeded.

JsonDecodedDocument (interface)

sealed interface JsonDecodedDocument

What jsonDecodeDocument answers: the document, or why there is none. The cases are JsonParsedDocument, JsonMalformed and JsonLimitExceeded.

JsonParsed (class)

class JsonParsed(val value: Json) : JsonDecoded

The input is one JSON value within the limits: value is it.

JsonParsedDocument (class)

class JsonParsedDocument(val document: JsonDocument) : JsonDecodedDocument

The input is one JSON document within the limits: document is it.

JsonMalformed (class)

class JsonMalformed(val error: JsonError) : JsonDecoded, JsonDecodedDocument

The input is not JSON, or breaks a rule of the grammar the limits do not govern. error.code is unexpected_token, unexpected_end, invalid_number, trailing_input, invalid_unicode or duplicate_key.

JsonLimitExceeded (class)

class JsonLimitExceeded(val error: JsonError) : JsonDecoded, JsonDecodedDocument

The input is more than the limits allow (JsonLimits), however well formed. error.code is input_limit, node_limit or depth_limit.

jsonDecode (fun)

fun jsonDecode(source: string, limits: JsonLimits = jsonDefaultLimits()): JsonDecoded

source decoded under limits with jsonParse's rules: JsonParsed with the value, JsonMalformed or JsonLimitExceeded with the error jsonParse reports.

jsonDecodeDocument (fun)

fun jsonDecodeDocument(source: string, limits: JsonLimits = jsonDefaultLimits()): JsonDecodedDocument

jsonDecode into a tape document (jsonDocument's), for the same input and limits.

$json (sub-language)

#compilerRegisterSubparser("json", ablaJsonParseValue)

Registers the JSON literal parser that returns a typed JSON value and reports malformed syntax.

$jsons (sub-language)

#compilerRegisterSubparser("jsons", ablaJsonParseStringifiedValue)

Registers the JSON literal parser that returns a serialized string and reports malformed syntax.

$jsonw (sub-language)

#compilerRegisterSubparser("jsonw", ablaJsonParseWrittenValue)

Registers the JSON writer literal that appends a value to a mutable buffer and reports malformed syntax.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.