Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 56 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5417,8 +5417,10 @@ <h3>Algorithm</h3>
<li>Otherwise <var>value</var> is an
<a>RDF literal</a>:
<ol>
<li>Initialize a new empty <a class="changed">map</a> result.</li>
<li>Initialize <var>converted value</var> to <var>value</var>.</li>
<li>Initialize a new empty <a class="changed">map</a> <var>result</var>.</li>
<li>
Initialize <var>converted value</var> to <var>null</var>.
</li>
<li>Initialize <var>type</var> to <code>null</code></li>
<li>If <a data-link-for="JsonLdOptions">useNativeTypes</a> is <code>true</code>
<ol>
Expand All @@ -5433,12 +5435,8 @@ <h3>Algorithm</h3>
of <var>value</var> equals <code>xsd:boolean</code>, set
<var>converted value</var> to <code>true</code> if the
<a>lexical form</a>

of <var>value</var> matches <code>"true"</code> or <code>"1"</code>, or <code>false</code>
if it matches <code>"false"</code> or <code>"0"</code>.

If it matches neither,
set <var>type</var> to <code>xsd:boolean</code>.</li>
of <var>value</var> matches <code>"true"</code> or <code>"1"</code>, or <code>false</code>
if it matches <code>"false"</code> or <code>"0"</code>.</li>
<li>Otherwise, if the
<a>datatype IRI</a>
of <var>value</var> equals <code>xsd:integer</code> or
Expand All @@ -5458,46 +5456,47 @@ <h3>Algorithm</h3>
If the conversion is successful, set <var>converted value</var>
to its result.
</li>
<li>
Otherwise, set <var>type</var> to <a>datatype IRI</a>
of <var>value</var>.
</li>
</ol>

</li>
</ol>
</li>
<li class="changed">Otherwise, if <a>processing mode</a> is not `json-ld-1.0`,
and <var>value</var> is a <a>JSON literal</a>,
set <var>converted value</var> to the result of
turning the lexical value of <var>value</var>
into the <a>JSON-LD internal representation</a>, and set <var>type</var> to <code>@json</code>.
If the lexical value of <var>value</var> is not valid JSON according to
the <a data-cite="RFC8259#section-2">JSON Grammar</a> [[RFC8259]],
an <a data-link-for="JsonLdErrorCode">invalid JSON literal</a>
error has been detected and processing is aborted.</li>
<li class="changed">Otherwise, if the <a>datatype IRI</a> of <var>value</var> starts with `https://www.w3.org/ns/i18n#`,
and {{JsonLdOptions/rdfDirection}} is `i18n-datatype`:
<ol>
<li class="changed">
If <var>converted value</var> is <code>null</code>,
<ol class="changed">
<li>Set <var>converted value</var> to the <a>lexical form</a> of <var>value</var>.</li>
<li>If the string prefix of the <a data-cite="RFC3986#section-3.5">fragment identifier</a>
of the <a>datatype IRI</a> up until the underscore (`"_"`) is not empty,
add an <a>entry</a> `@language` to <var>result</var> and set its value to that prefix.
<div class="note">As `@direction` may be used without `@language`,
it is possible, and legitimate, to create a datatype IRI
such as `http://w3.org/ns/i18n#_ltr`, which does not encode a language tag.</div></li>
<li>Add an <a>entry</a> `@direction` to <var>result</var> and set its value to the substring of the
<a data-cite="RFC3986#section-3.5">fragment identifier</a> following
the underscore (`"_"`).</li>
<li>If <a>processing mode</a> is not `json-ld-1.0`,
and <var>value</var> is a <a>JSON literal</a>,
set <var>converted value</var> to the result of
turning the lexical value of <var>value</var>
into the <a>JSON-LD internal representation</a>, and set <var>type</var> to <code>@json</code>.
If the lexical value of <var>value</var> is not valid JSON according to
the <a data-cite="RFC8259#section-2">JSON Grammar</a> [[RFC8259]],
an <a data-link-for="JsonLdErrorCode">invalid JSON literal</a>
error has been detected and processing is aborted.</li>
<li>Otherwise, if the <a>datatype IRI</a> of <var>value</var> starts with `https://www.w3.org/ns/i18n#`,
and {{JsonLdOptions/rdfDirection}} is `i18n-datatype`:
<ol>
<li>If the string prefix of the <a data-cite="RFC3986#section-3.5">fragment identifier</a>
of the <a>datatype IRI</a> up until the underscore (`"_"`) is not empty,
add an <a>entry</a> `@language` to <var>result</var> and set its value to that prefix.
<div class="note">As `@direction` may be used without `@language`,
it is possible, and legitimate, to create a datatype IRI
such as `http://w3.org/ns/i18n#_ltr`, which does not encode a language tag.</div></li>
<li>Add an <a>entry</a> `@direction` to <var>result</var> and set its value to the substring of the
<a data-cite="RFC3986#section-3.5">fragment identifier</a> following
the underscore (`"_"`).</li>
</ol>
</li>
<li>Otherwise, if <var>value</var> is a
<a>language-tagged string</a>
add an <a>entry</a> <code>@language</code> to <var>result</var> and set its value to the
<a>language tag</a> of <var>value</var>.</li>
<li>Otherwise, set <var>type</var> to the
<a>datatype IRI</a>
of <var>value</var>, unless it equals <code>xsd:string</code> which is ignored.</li>
</ol>
</li>
<li>Otherwise, if <var>value</var> is a
<a>language-tagged string</a>
add an <a>entry</a> <code>@language</code> to <var>result</var> and set its value to the
<a>language tag</a> of <var>value</var>.</li>
<li>Otherwise, set <var>type</var> to the
<a>datatype IRI</a>
of <var>value</var>, unless it equals <code>xsd:string</code> which is ignored.</li>
<li>Add an <a>entry</a> <code>@value</code> to <var>result</var> whose value
is set to <var>converted value</var>.</li>
<li>If <var>type</var> is not <code>null</code>, add an <a>entry</a> <code>@type</code>
Expand Down Expand Up @@ -7034,6 +7033,23 @@ <h2>Change log</h2>
once and for all in this step, rather than in each iteration.
For more information, refer to <a href="https://github.com/w3c/json-ld-api/issues/633">issue 633</a>.
</li>
<li>
2026-06-06:
Fix the
<a href="#rdf-to-object-conversion">RDF to Object Conversion algorithm</a>,
which unconditionally skipped `else` clauses when
<a data-link-for="JsonLdOptions">useNativeTypes</a> was `true`, even if a
native type couldn't be used. This resulted in plain strings where, e.g.,
language-tagged string literals were the source.
Instead, let <var>converted value</var> be initially unset, and only
actively set if a native type can be used. Then group the other cases
in an `else` block, defaulting to use the lexical form of
<var>value</var>. Since <var>type</var> is set in the final `else` clause
(unless it equals <var>xsd:string</var>), there is no need to set it in
the clause for <var>useNativeTypes</var>.
For more information, refer to
<a href="https://github.com/w3c/json-ld-api/issues/670">issue 670</a>.
</li>
</ul>
</details>

Expand Down
10 changes: 10 additions & 0 deletions tests/fromRdf-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@
},
"input": "fromRdf/0027-in.nq",
"expect": "fromRdf/0027-out.jsonld"
}, {
"@id": "#t0028",
"@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],
"name": "use native types flag with non-native values",
"purpose": "Ensure that useNativeTypes flag being true does not interfere with values that cannot be serialized into a native value.",
"option": {
"useNativeTypes": true
},
"input": "fromRdf/0028-in.nq",
"expect": "fromRdf/0028-out.jsonld"
}, {
"@id": "#tdi01",
"@type": [ "jld:PositiveEvaluationTest", "jld:FromRDFTest" ],
Expand Down
5 changes: 5 additions & 0 deletions tests/fromRdf/0028-in.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<http://example.com> <http://example.com/property> "string" .
<http://example.com> <http://example.com/property> "hello"@en .
<http://example.com> <http://example.com/property> "No"^^<http://www.w3.org/2001/XMLSchema#boolean> .
<http://example.com> <http://example.com/property> "AAA"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://example.com> <http://example.com/property> "{\"x\": 1}"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON> .
28 changes: 28 additions & 0 deletions tests/fromRdf/0028-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"@id": "http://example.com",
"http://example.com/property": [
{
"@value": "string"
},
{
"@language": "en",
"@value": "hello"
},
{
"@value": "No",
"@type": "http://www.w3.org/2001/XMLSchema#boolean"
},
{
"@value": "AAA",
"@type": "http://www.w3.org/2001/XMLSchema#double"
},
{
"@value": {
"x": 1
},
"@type": "@json"
}
]
}
]
Loading