Manuscript Documentation
v0.1.0

@std/json.ms#

Import each required symbol with import Name from "@std/json.ms".

JsonError Alternative#

Errors returned for malformed JSON or configured input and nesting limits.

Manuscript
type JsonError:
    case InvalidInput
    case InvalidData
    case LimitExceeded
Manuscript
impl Error for JsonError:
    fn message() -> String:

JsonError.InvalidData#

JSON syntax, Unicode escapes, duplicate keys, number text or a cyclic value is invalid.

Manuscript
case InvalidData

JsonError.InvalidInput#

An explicit input, depth, value-count or output budget is negative.

Manuscript
case InvalidInput

JsonError.LimitExceeded#

The input, nesting, value count or encoded output exceeds a supplied budget.

Manuscript
case LimitExceeded

JsonError.Error.message#

Returns a JSON-prefixed diagnostic without echoing input text or number tokens.

Manuscript
fn message() -> String:

JsonLimits Record#

Optional bounds for JSON input bytes, nesting depth, and parsed values.

Manuscript
type JsonLimits:
    max_bytes: Optional[Int] = none
    max_depth: Optional[Int] = none
    max_values: Optional[Int] = none

JsonLimits.max_bytes#

Maximum UTF-8 input bytes before parsing; none adds no input-size budget.

Manuscript
max_bytes: Optional[Int] = none

JsonLimits.max_depth#

Maximum container nesting; a root scalar has depth zero, and a root container depth one.

Manuscript
max_depth: Optional[Int] = none

JsonLimits.max_values#

Maximum parsed containers and scalar values, excluding object keys; none adds no count budget.

Manuscript
max_values: Optional[Int] = none

JsonValue Alternative#

A JSON value. Number text is retained to avoid losing precision during parsing.

Manuscript
type JsonValue:
    case Null
    case BoolValue(value: Bool)
    case NumberValue(text: String)
    case StringValue(value: String)
    case ArrayValue(values: List[JsonValue])
    case ObjectValue(values: Map[String, JsonValue])

JsonValue.ArrayValue#

An ordered JSON array whose mutable list can be updated before serialization.

Manuscript
case ArrayValue(values: List[JsonValue])

JsonValue.BoolValue#

A JSON true or false value.

Manuscript
case BoolValue(value: Bool)

JsonValue.Null#

JSON null, represented without a payload value.

Manuscript
case Null

JsonValue.NumberValue#

An exact JSON number token; parsing does not coerce it into Float.

Manuscript
case NumberValue(text: String)

JsonValue.ObjectValue#

A JSON object retaining insertion order and rejecting duplicate keys during parsing.

Manuscript
case ObjectValue(values: Map[String, JsonValue])

JsonValue.StringValue#

A decoded JSON string, with escapes resolved into Unicode text.

Manuscript
case StringValue(value: String)

JsonValue.ArrayValue.values#

Element values in source order; nested mutable payloads retain their references.

Manuscript
values: List[JsonValue]

JsonValue.BoolValue.value#

The decoded boolean, without a textual representation requirement.

Manuscript
value: Bool

JsonValue.NumberValue.text#

Original numeric token text; stringify validates its JSON number syntax.

Manuscript
text: String

JsonValue.ObjectValue.values#

String-keyed members in insertion order; stringify reads their current values.

Manuscript
values: Map[String, JsonValue]

JsonValue.StringValue.value#

Decoded UTF-8 text, preserving scalar contents without normalization.

Manuscript
value: String

parse Function#

Parses one JSON value and applies the supplied input, depth, and value limits.

Manuscript
fn parse(text: String, limits: Optional[JsonLimits] = none) -> Result[JsonValue, JsonError]:

stringify Function#

Serializes a JSON value. max_bytes bounds output when supplied.

Manuscript
fn stringify(value: JsonValue, max_bytes: Optional[Int] = none) -> Result[String, JsonError]: