Esc

json_reader_init

procedureextensionsince 0.36.1Source
  • macOS: json_reader_init works on macOS
  • Linux: json_reader_init works on Linux
  • Windows: json_reader_init works on Windows
  • Wasm: json_reader_init works on Wasm

Starts a reader over text for a decoder written by hand instead of generated from a type. Read with the procedures above, then call json_reader_error for a failure and json_reader_free in any case.

Signature

json_reader_init :: (r: *Json_Reader, text: string, options := Json_Options.{})
Example↗
r: Json_Reader;
json_reader_init(*r, "[1, 2]");
defer json_reader_free(*r);
total: s64;
first := true;
ok := json_begin_array(*r);
while ok && json_array_next(*r, *first) == .ITEM {
    n: s64;
    ok = json_read_signed(*r, *n, 0, 10, "digit");
    total += n;
}
assert(ok && total == 3);

See also