Skip to content

change definition of rdf:JSON #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 14, 2025
Merged
Changes from 1 commit
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
44 changes: 9 additions & 35 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1843,47 +1843,17 @@ <h3>The <code>rdf:JSON</code> Datatype</h3>
<a>strings</a>,
numbers (<a data-cite="XMLSCHEMA11-2#double"><strong>xsd:double</strong></a>),
<a data-cite="INFRA#ordered-map">maps</a>
(mapping <a>strings</a> to values in the <a href="#JSON-value-space">value space</a> where the order of <a data-cite="INFRA#map-entry">map entries</a> is not significant),
mapping <a>strings</a> to values in the <a href="#JSON-value-space">value space</a> where the key-value pairs are ordered by key (using <a data-cite="I18N-GLOSSARY#dfn-code-point" class="lint-ignore">Unicode code points</a> order),
<a data-cite="INFRA#list">lists</a>
(of values in the <a href="#JSON-value-space">value space</a>), and
of values in the <a href="#JSON-value-space">value space</a>, and
literal values (<a data-cite="INFRA#boolean">`true`, `false`</a>, and <a data-cite="INFRA#nulls">`null`</a>)
from [[[INFRA]]] [[INFRA]] and [[[XMLSCHEMA11-2]]] [[XMLSCHEMA11-2]].

<p class="note">The value space of <a data-cite="INFRA#ordered-map">maps</a>
and <a data-cite="INFRA#list">lists</a> does not include values having themselves as members,
which cannot be represented in JSON.</p>

<p>Two values (|a| and |b|) are considered equal if any of the following are true:
<ul>
<li>They are the same <a>string</a>,
number (<a data-cite="XMLSCHEMA11-2#double"><strong>xsd:double</strong></a>), or
literal value.</li>
<li>They are both <a data-cite="INFRA#list">lists</a> containing <a data-cite="INFRA#list-item">items</a>
which are pairwise equal – meaning that each <a data-cite="INFRA#list-item">item</a>
in |a| is equal the <a data-cite="INFRA#list-item">item</a>
at the corresponding index in |b|,
and both |a| and |b| have the same <a data-cite="INFRA#list-size">size</a>.</li>
<li>They are both <a data-cite="INFRA#ordered-map">maps</a> with equal <a data-cite="INFRA#map-entry">entries</a>
– meaning that for each entry <var>e<sub>a</sub></var> in |a|
there exists an entry <var>e<sub>b</sub></var> in |b|
such that the <a data-cite="INFRA#map-key">key</a> in <var>e<sub>a</sub></var>
equals the <a data-cite="INFRA#map-key">key</a> in <var>e<sub>b</sub></var>,
the <a data-cite="INFRA#map-value">value</a> in <var>e<sub>a</sub></var>
equals the <a data-cite="INFRA#map-value">value</a> in <var>e<sub>b</sub></var>,
and both |a| and |b| have the same <a data-cite="INFRA#map-size">size</a>.
<div class="note">Two JSON Objects containing maps which are serialized with entries in a different order will be equal under this definition when transformed to the value space.
For example, `{ "a": 1, "b": 2 } and { "b": 2, "a": 1 }` are considered equal.
As a result of the value space being defined using terminology from [[INFRA]],
property values which can contain more than one item, such as <a data-cite="INFRA#list">lists</a> and <a data-cite="INFRA#ordered-map">maps</a>,
are explicitly ordered.
All list-like value structures in [[INFRA]] are ordered,
whether or not that order is significant.
For the purposes of this specification, unless otherwise stated,
<a data-cite="INFRA#ordered-map">map</a> ordering is not important
and implementations are not expected to produce or consume deterministically ordered values.
</div>
</li>
</ul>
<p>Two values are considered equal if and only if they are the same element of the value space.</p>
</dd>

<dt id="JSON-mapping">The <a>lexical-to-value mapping</a></dt>
Expand All @@ -1899,8 +1869,9 @@ <h3>The <code>rdf:JSON</code> Datatype</h3>
by transforming each object member into a <a data-cite="INFRA#map-entry">map entry</a>
with the <a data-cite="INFRA#map-key">key</a> taken from the member name and
<a data-cite="INFRA#map-value">value</a> taken by performing this mapping
to the member value.
<a data-cite="INFRA#map-entry">Map entries</a> are treated as being unordered.
to the member value,
and sorting the entryes by key ()
(using <a data-cite="I18N-GLOSSARY#dfn-code-point" class="lint-ignore">Unicode code points</a> order).
</li>
<li>A <a data-cite="RFC8259#section-5">JSON Array</a> is mapped to a <a data-cite="INFRA#list">list</a>
such that this <a data-cite="INFRA#list">list</a> contains as many
Expand Down Expand Up @@ -1931,6 +1902,9 @@ <h3>The <code>rdf:JSON</code> Datatype</h3>
</ul>
</dd>
</dl>
<p class="note">
The constraint to order map entries in the value space is only meant to make the order of object-member the lexical space irrelevant. In other word, it ensures that both lexical values <code>{"a": "b", "c": "d"}</code> and <code>{"c": "d", "a": "b"}</code> are mapped to the same element of the value space. Implementations may omit to sort the entries, as long as they treat the maps in the value space as unordered.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The constraint to order map entries in the value space is only meant to make the order of object-member the lexical space irrelevant. In other word, it ensures that both lexical values <code>{"a": "b", "c": "d"}</code> and <code>{"c": "d", "a": "b"}</code> are mapped to the same element of the value space. Implementations may omit to sort the entries, as long as they treat the maps in the value space as unordered.
The constraint to order map entries in the value space is only meant to make the order of map entries in the lexical space irrelevant. In other words, it ensures that both lexical values <code>{"a": "b", "c": "d"}</code> and <code>{"c": "d", "a": "b"}</code> are mapped to the same element of the value space. Implementations may omit to sort the entries, as long as they treat the maps in the value space as unordered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the lexical space is made of strings, not of maps... So technically, there are no map entries in the lexical space. "object member" refers to the terms in the JSON grammar, and therefore is more appropriate for talking about the lexical space.

Copy link
Contributor Author

@pchampin pchampin Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that, "object-member" should have been plural, and indeed "word" as well... This is fixed in 215a18e .

</p>
<p class="issue" data-number="116">The issue refers to the use
of <a data-cite="INFRA#ordered-map">ordered map</a>
from [[INFRA]] for describing the value space of <a data-cite="RFC8259#section-4">JSON Objects</a>
Expand Down
Loading