JSON canonicalization (JCS)
The RFC 8785 canonical form of text, a JSON text. JSON texts are RFC 8259 JSON of at most 1,048,576 UTF-8 bytes (whitespace: space, tab, LF, CR; a BOM is an error) under I-JSON rules: a duplicate member name (after unescaping), a \u escape of an unpaired surrogate, nesting over 128 deep ([] is depth 1), or a number that rounds to ±infinity is an error; numbers are read as the nearest double (ties to even), so 1e-400 is 0. JSON output is RFC 8785 (JCS) canonical: no whitespace; members sorted by the UTF-16 code units of their names; in strings only " and \ are escaped and U+0000-U+001F written \b \t \n \f \r or \u00xx (lowercase hex), all else literal; numbers as ECMAScript's Number.prototype.toString writes the double (-0 as 0, 1e21 as 1e+21, 1e-7 as 1e-7).
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init data-json-canonicalize --lang rustcd data-json-canonicalize && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty data-json-canonicalize: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)11 lines›
package root:component;
world root {
export liberas:data/convert@0.1.0;
}
package liberas:data@0.1.0 {
interface convert {
convert: func(text: string) -> result<string, string>;
}
}
Test vectors31›
[
{
"args": {
"text": "{\"numbers\": [333333333.33333329, 1E30, 4.50, 2e-3, 0.000000000000000000000000001], \"string\": \"\\u20ac$\\u000F\\u000aA'\\u0042\\u0022\\u005c\\\\\\\"\\/\", \"literals\": [null, true, false]}"
}
},
{
"args": {
"text": "{\"\\u20ac\": \"Euro Sign\", \"\\r\": \"Carriage Return\", \"\\ufb33\": \"Hebrew Letter Dalet With Dagesh\", \"1\": \"One\", \"\\ud83d\\ude00\": \"Emoji: Grinning Face\", \"\\u0080\": \"Control\", \"\\u00f6\": \"Latin Small Letter O With Diaeresis\"}"
}
},
{
"args": {
"text": "[-0, 0.0, -0.0e5, 1e21, 1e20, 123456789012345678901, 9007199254740993, 5e-324, 1.7976931348623157e308, 1e-7, 0.000001, 1.5e-7, -1e-400, 0.1, 100, 1E+2, 12.34e-10, 2.5e25]"
}
},
{
"args": {
"text": " \t\n\r{ \"b\" : [ ] , \"a\" : { } , \"c\" : \" \\u001f\\b\\/\" }\r\n"
}
},
{
"args": {
"text": "\"é\\u00e9\\uD834\\uDD1E𝄞\""
}
},
{
"args": {
"text": "true"
}
},
{
"args": {
"text": "null"
}
},
{
"args": {
"text": "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
}
},
{
"args": {
"text": "{\"a\":1,\"a\":2}"
}
},
{
"args": {
"text": "{\"a\":1,\"\\u0061\":2}"
}
},
{
"args": {
"text": "\"\\ud800\""
}
},
{
"args": {
"text": "\"\\udc00\\ud800\""
}
},
{
"args": {
"text": "\"\\ud800\\u0041\""
}
},
{
"args": {
"text": "1e400"
}
},
{
"args": {
"text": "-1.8e308"
}
},
{
"args": {
"text": "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
}
},
{
"args": {
"text": "[1,]"
}
},
{
"args": {
"text": "01"
}
},
{
"args": {
"text": "1."
}
},
{
"args": {
"text": ".5"
}
},
{
"args": {
"text": "+1"
}
},
{
"args": {
"text": "{}"
}
},
{
"args": {
"text": ""
}
},
{
"args": {
"text": " "
}
},
{
"args": {
"text": "NaN"
}
},
{
"args": {
"text": "\"\u0001\""
}
},
{
"args": {
"text": "\"\\x41\""
}
},
{
"args": {
"text": "{'a':1}"
}
},
{
"args": {
"text": "[1] [2]"
}
},
{
"args": {
"text": "tru"
}
},
{
"args": {
"text": "{\"a\"}"
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 31 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 2,500,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.