constJSON_MOST_DEPTH
const JSON_MOST_DEPTH = 500
json: reads and writes JSON, the text format most save files and web services use. use "json.jamo"
A Json value is null, a bool, a number, text, a list or an object. Objects keep their keys in the order they were added. parse_json never stops the program: when the text isn't JSON, the value it gives back has an error that says what's wrong and on which line.
const JSON_MOST_DEPTH = 500
enum JsonKind
NULL
BOOL
NUMBER
TEXT
LIST
OBJECT
endstruct Json
kind: JsonKind
truth: bool
number: float
text: string
items: [Json]
keys: [string]
values: [Json]
error: string
endfunc json_null(): Json
func json_bool(value: bool): Json
func json_number(value: float): Json
func json_int(value: int): Json
func json_text(value: string): Json
func json_list(): Json
func json_object(): Json
func Json.add(item: Json)
Adds an item to the end of a list
func Json.set(key: string, value: Json)
Sets a key in an object, replacing what it had
func Json.has(key: string): bool
func index_of_key(keys: [string], key: string): int
func Json.get(key: string): Json
An object's value for a key, or null when it has no such key
func Json.at(place: int): Json
A list's item at a place, counting from 0, or null when there's nothing there
func Json.size(): int
How many items a list has, or keys an object has
func Json.is_null(): bool
func Json.as_int(): int
The number as an int, dropping any decimals. Anything that isn't a number gives 0
func json_escape(text: string, out: TextBuilder)
func json_number_text(value: float): string
Whole numbers are written without decimals. Others show up to 6 decimals, the way Jamo shows floats. JSON has no NaN or infinity, so they're written as null
func json_write(value: Json, out: TextBuilder, pretty: bool, depth: int)
func json_new_line(out: TextBuilder, pretty: bool, depth: int)
func to_json(value: Json): string
The value as JSON on one line
func to_json_pretty(value: Json): string
The value as JSON, one item a line and indented, for files people may read
struct JsonReader
text: string
at: int
line: int
error: string
endfunc JsonReader.fail_here(words: string)
func JsonReader.next_byte(): int
func JsonReader.skip_space()
func JsonReader.word(text: string): bool
func slice_or_empty(text: string, from: int, to: int): string
func JsonReader.read_value(depth: int): Json
func JsonReader.read_list(depth: int): Json
func JsonReader.read_object(depth: int): Json
func json_hex(code: int): int
func JsonReader.read_hex4(): int
func json_add_utf8(out: TextBuilder, code: int)
func JsonReader.read_text(): string
Reads text in double quotes, starting at the opening quote
func json_byte(value: int): int
func is_digit_code(code: int): bool
func JsonReader.read_number(): Json
Reads a number. The exponent moves the decimal point in the digits themselves, so the answer rounds exactly
func parse_json(text: string): Json
Reads JSON text. When it isn't JSON, the answer is null with an error saying why, and the line