YAML to JSON
text, a YAML 1.2.2 stream of at most 1,048,576 UTF-8 bytes holding exactly one document, as JSON written as data-json-canonicalize writes it; text that is not valid YAML is an error (the reference is saphyr-parser 0.2.2). Scalars resolve by the core schema (YAML 1.2.2, section 10.3.2): an untagged plain scalar that is empty, ~, null, Null or NULL is null; true, True, TRUE, false, False, FALSE a boolean; [-+]?[0-9]+, 0o[0-7]+ or 0x[0-9a-fA-F]+ an integer, as the nearest double (0o and 0x over 64 bits are an error); [-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)? a float, as the nearest double; [-+]?(.inf|.Inf|.INF) and .nan, .NaN, .NAN an error; any other plain scalar, and every quoted or block scalar, a string. Tags: ! (a string, or as untagged for a collection), !!str, !!null, !!bool, !!int and !!float (the scalar, whatever its style, must have that type's form), !!seq and !!map; any other tag is an error. A sequence becomes an array, a mapping an object: each key must be a scalar or an alias of one, and its member name is the key's content as written (so 1 and '1' are the same name); a repeated name is an error; << is an ordinary key. Aliases are expanded; an alias of a node it is inside is an error. Errors too: a number out of the range of a double, nesting over 128 deep (each sequence and mapping a level; the outermost is level 1), a result over 4,194,304 bytes, a stream with no document.
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init data-yaml-to-json --lang rustcd data-yaml-to-json && 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-yaml-to-json: 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 vectors50›
[
{
"args": {
"text": "- Mark McGwire\n- Sammy Sosa\n- Ken Griffey\n"
}
},
{
"args": {
"text": "hr: 65 # Home runs\navg: 0.278 # Batting average\nrbi: 147 # Runs Batted In\n"
}
},
{
"args": {
"text": "american:\n- Boston Red Sox\n- Detroit Tigers\nnational:\n- New York Mets\n- Chicago Cubs\n"
}
},
{
"args": {
"text": "-\n name: Mark McGwire\n hr: 65\n avg: 0.278\n-\n name: Sammy Sosa\n hr: 63\n avg: 0.288\n"
}
},
{
"args": {
"text": "Mark McGwire: {hr: 65, avg: 0.278}\nSammy Sosa: {\n hr: 63,\n avg: 0.288,\n }\n"
}
},
{
"args": {
"text": "---\nhr:\n- Mark McGwire\n# Following node labeled SS\n- &SS Sammy Sosa\nrbi:\n- *SS # Subsequent occurrence\n- Ken Griffey\n"
}
},
{
"args": {
"text": "# ASCII Art\n--- |\n \\//||\\/||\n // || ||__\n"
}
},
{
"args": {
"text": ">\n Sammy Sosa completed another\n fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\n What a year!\n"
}
},
{
"args": {
"text": "unicode: \"Sosa did fine.\\u263A\"\ncontrol: \"\\b1998\\t1999\\t2000\\n\"\nhex esc: \"\\x0d\\x0a is \\r\\n\"\n\nsingle: '\"Howdy!\" he cried.'\nquoted: ' # Not a ''comment''.'\ntie-fighter: '|\\-*-/|'\n"
}
},
{
"args": {
"text": "canonical: 12345\ndecimal: +12345\noctal: 0o14\nhexadecimal: 0xC\n"
}
},
{
"args": {
"text": "canonical: 1.23015e+3\nexponential: 12.3015e+02\nfixed: 1230.15\n"
}
},
{
"args": {
"text": "null:\nbooleans: [ true, false ]\nstring: '012345'\n"
}
},
{
"args": {
"text": "---\nnot-date: !!str 2002-04-28\n"
}
},
{
"args": {
"text": "[~, null, Null, NULL, nULL, '', \"null\", True, TRUE, tRUE, yes, on, 0, -0, +1, 007, 0o17, 0O17, 0x1f, 0xFF, 0X1, +0x1, 1_000, .5, -.5, 1., 1e3, 1E-3, +1.5e+3, 1.e1, e3, .e3, 1e, 0b101, 2001-12-14, 12:30]"
}
},
{
"args": {
"text": "a: !!str 1\nb: !!int '2'\nc: !!float 3\nd: !!bool \"true\"\ne: !!null ''\nf: ! 4\ng: !!seq [1]\nh: !!map {x: 1}\ni: !<tag:yaml.org,2002:int> 5\nj: ! [1]\n"
}
},
{
"args": {
"text": "&k key: &v value\nlist: [*v, *k]\nmap: {*v : *k}\n"
}
},
{
"args": {
"text": "base: &b {x: 1, y: [a, b]}\ncopy: *b\nnested: [*b, {inner: *b}]\n"
}
},
{
"args": {
"text": "1: one\n0x1: hex\n~: tilde\n: empty\n\"a b\": c\n<<: {merge: no}\n"
}
},
{
"args": {
"text": "z: 1\nb: 2\né: 3\n😀: 4\nff: 5\n"
}
},
{
"args": {
"text": "%YAML 1.2\n---\nseq:\n - [a, [b, [c]]]\n - {}\n - []\n...\n"
}
},
{
"args": {
"text": "literal: |+\n keep\n\nfolded: >-\n a\n b\nplain: multi\n line\n"
}
},
{
"args": {
"text": "big: 9007199254740993\nsmall: 1e-400\nneg: -9223372036854775808\nhex: 0xffffffffffffffff\noct: 0o1777777777777777777777\n"
}
},
{
"args": {
"text": "---\n...\n"
}
},
{
"args": {
"text": "x: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
}
},
{
"args": {
"text": ""
}
},
{
"args": {
"text": "# only a comment\n"
}
},
{
"args": {
"text": "--- 1\n--- 2\n"
}
},
{
"args": {
"text": "a: 1\na: 2\n"
}
},
{
"args": {
"text": "1: a\n'1': b\n"
}
},
{
"args": {
"text": "? [a]\n: 1\n"
}
},
{
"args": {
"text": "{a: 1}: b\n"
}
},
{
"args": {
"text": "&a [*a]\n"
}
},
{
"args": {
"text": "a: !!binary aGk=\n"
}
},
{
"args": {
"text": "a: !foo b\n"
}
},
{
"args": {
"text": "a: !!int x\n"
}
},
{
"args": {
"text": "a: !!null 0\n"
}
},
{
"args": {
"text": "a: !!bool yes\n"
}
},
{
"args": {
"text": "a: !!float .nan\n"
}
},
{
"args": {
"text": "a: !!seq {}\n"
}
},
{
"args": {
"text": "a: .inf\n"
}
},
{
"args": {
"text": "a: -.Inf\n"
}
},
{
"args": {
"text": "a: .NaN\n"
}
},
{
"args": {
"text": "a: 1e400\n"
}
},
{
"args": {
"text": "a: 0x10000000000000000\n"
}
},
{
"args": {
"text": "a: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"args": {
"text": "x: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
}
},
{
"args": {
"text": "a: [1, 2\n"
}
},
{
"args": {
"text": "a: b: c\n"
}
},
{
"args": {
"text": "a: 'unterminated\n"
}
},
{
"args": {
"text": "- *missing\n"
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 50 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 10,000,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.