code / tomo-json

Lines232 Tomo203 Markdown26 INI3

JSON

This is a Tomo library for encoding/decoding JSON values.

Usage

1 >> j := JSON({"key1"=123, "key2"=[yes, {"ok"="inner"}, JSON.Null]})
2 = JSON.Object({"key1"=Number(123), "key2"=Array([Boolean(yes), Object({"ok"=String("inner")}), Null])})
4 say("$(j.encode())")
5 say("$(j.pretty_print())")
7 when JSON.parse("[1, null, true]") is Success(obj)
8 >> obj
9 is Failure(msg)
10 fail("Failed to parse JSON: $msg")