Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
data / data-json-pointerOpenRuns on Liberas

JSON Pointer

The value in document, a JSON text, that pointer (RFC 6901) refers to, in canonical form. pointer is empty (the whole document) or '/' followed by reference tokens separated by '/'; in a token '~0' is '~' and '~1' is '/', and any other '~' is an error. Each token selects, in turn, an object's member by its exact name or an array's element by index: '0' or ASCII digits without a leading zero, less than the array's length. An index that is not of that form or out of range ('-' included), a missing member, a token applied to a string, number, true, false or null, or a pointer of over 1,048,576 bytes is an error. 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

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init data-json-pointer --lang rust
cd data-json-pointer && 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).

Interface (WIT)11 lines›
data-json-pointer.wit
package root:component;

world root {
  export liberas:data/pointer@0.1.0;
}
package liberas:data@0.1.0 {
  interface pointer {
    get: func(document: string, pointer: string) -> result<string, string>;
  }
}
Test vectors27›
data-json-pointer.cases.json
[
  {
    "args": {
      "pointer": "",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/0",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/a~1b",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/c%d",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/e^f",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/g|h",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/i\\j",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/k\"l",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/ ",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/m~0n",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "foo",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/-",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/01",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/2",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/1e0",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/m~2n",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/m~",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/nope",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/foo/0/x",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/ /x",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "//",
      "document": "{\"foo\": [\"bar\", \"baz\"], \"\": 0, \"a/b\": 1, \"c%d\": 2, \"e^f\": 3, \"g|h\": 4, \"i\\\\j\": 5, \"k\\\"l\": 6, \" \": 7, \"m~n\": 8}"
    }
  },
  {
    "args": {
      "pointer": "/a//b/0/~0~1",
      "document": "{\"a\":{\"\":{\"b\":[{\"~/\":[-0.0,1e21]}]}}}"
    }
  },
  {
    "args": {
      "pointer": "/a//b/0/~0~1/1",
      "document": "{\"a\":{\"\":{\"b\":[{\"~/\":[-0.0,1e21]}]}}}"
    }
  },
  {
    "args": {
      "pointer": "",
      "document": "[1,2"
    }
  },
  {
    "args": {
      "pointer": "/a",
      "document": "{\"a\":1,\"a\":1}"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 27 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,000,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.