Json module

to_json

procedureextensionSource

Encodes value. Output is compact unless pretty (two-space indent). The result comes from context.allocator.

Example↗
Point :: struct { x: int; y: int; }

text := to_json(Point.{ 1, 2 });
assert(text == "{\"x\":1,\"y\":2}");
free(text);
to_json :: (value: $T, pretty := false) -> string

Encodes value. Output is compact unless pretty (two-space indent). The result comes from context.allocator.

Parameters

value: $T
pretty := false
indents with two spaces and puts members on their own lines.

Returns

string
Example↗
Point :: struct { x: int; y: int; }

text := to_json(Point.{ 1, 2 });
assert(text == "{\"x\":1,\"y\":2}");
free(text);

See also