Skip to content

Commit 634c7d4

Browse files
committed
Add invalid JSON literal error and tests.
Fixes #149
1 parent dd0311b commit 634c7d4

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4981,7 +4981,11 @@ <h3>Algorithm</h3>
49814981
and <var>value</var> is a <a>JSON literal</a>,
49824982
set the <code>@value</code> <a>entry</a> to the result of
49834983
turning the lexical value of <var>value</var>
4984-
into the <a>JSON-LD internal representation</a>, and set <var>type</var> to <code>@json</code>.</li>
4984+
into the <a>JSON-LD internal representation</a>, and set <var>type</var> to <code>@json</code>.
4985+
If the the lexical value of <var>value</var> is not valid JSON according to
4986+
the <a data-cite="RFC8259#section-2">JSON Grammar</a> [[RFC8259]],
4987+
an <a data-link-for="JsonLdErrorCode">invalid JSON literal</a>
4988+
error has been detected and processing is aborted.</li>
49854989
<li>Otherwise, if <var>value</var> is a
49864990
<a>language-tagged string</a>
49874991
add a <a>entry</a> <code>@language</code> to <var>result</var> and set its value to the
@@ -6068,6 +6072,8 @@ <h4>JsonLdErrorCode</h4>
60686072
<dd>An <code>@id</code> <a>entry</a> was encountered whose value was not a <a>string</a>.</dd>
60696073
<dt><dfn>invalid @index value</dfn></dt>
60706074
<dd>An <code>@index</code> <a>entry</a> was encountered whose value was not a <a>string</a>.</dd>
6075+
<dt class="changed"><dfn>invalid JSON literal</dfn></dt>
6076+
<dd class="changed">An invalid JSON literal was detected.</dd>
60716077
<dt class="changed"><dfn>invalid @nest value</dfn></dt>
60726078
<dd class="changed">An invalid value for <code>@nest</code> has been found.</dd>
60736079
<dt class="changed"><dfn>invalid @prefix value</dfn></dt>

tests/fromRdf-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,22 @@
251251
"input": "fromRdf/js07-in.nq",
252252
"expect": "fromRdf/js07-out.jsonld",
253253
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"}
254+
}, {
255+
"@id": "#tjs08",
256+
"@type": ["jld:NegativeEvaluationTest", "jld:FromRDFTest"],
257+
"name": "Invalid JSON literal (bare-word)",
258+
"purpose": "Processors must generate an error when deserializing an invalid JSON literal.",
259+
"input": "fromRdf/js08-in.nq",
260+
"expect": "invalid JSON literal",
261+
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"}
262+
}, {
263+
"@id": "#tjs09",
264+
"@type": ["jld:NegativeEvaluationTest", "jld:FromRDFTest"],
265+
"name": "Invalid JSON literal (invalid structure)",
266+
"purpose": "Processors must generate an error when deserializing an invalid JSON literal.",
267+
"input": "fromRdf/js09-in.nq",
268+
"expect": "invalid JSON literal",
269+
"option": {"specVersion": "json-ld-1.1", "processingMode": "json-ld-1.1"}
254270
}, {
255271
"@id": "#tli01",
256272
"@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],

tests/fromRdf/js08-in.nq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<http://example.org/vocab#id> <http://example.org/vocab#invalid> "bareword"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON> .

tests/fromRdf/js09-in.nq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<http://example.org/vocab#id> <http://example.org/vocab#invalid> "[{]"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON> .

0 commit comments

Comments
 (0)