@@ -894,6 +894,10 @@ <h2>RDF Serialization/Deserialization</h2>
894
894
< th > IRI</ th >
895
895
</ tr > </ thead >
896
896
< tbody >
897
+ < tr >
898
+ < td > jsonld</ td >
899
+ < td > http://www.w3.org/ns/json-ld#</ td >
900
+ </ tr >
897
901
< tr >
898
902
< td > rdf</ td >
899
903
< td > http://www.w3.org/1999/02/22-rdf-syntax-ns#</ td >
@@ -1247,7 +1251,7 @@ <h3>Algorithm</h3>
1247
1251
< code > true</ code > for < var > vocab</ var > ,
1248
1252
< var > local context</ var > , and < var > defined</ var > . If the expanded < var > type</ var > is
1249
1253
neither < code > @id</ code > , nor < code > @vocab</ code > ,
1250
- < span class ="changed "> nor, if < a > processing mode</ a > is < code > json-ld-1.1</ code > , < code > @none</ code > ,</ span >
1254
+ < span class ="changed "> nor, if < a > processing mode</ a > is < code > json-ld-1.1</ code > , < code > @json </ code > nor < code > @ none</ code > ,</ span >
1251
1255
nor an < a > absolute IRI</ a > , an
1252
1256
< a data-link-for ="JsonLdErrorCode "> invalid type mapping</ a >
1253
1257
error has been detected and processing is aborted.</ li >
@@ -1715,7 +1719,12 @@ <h3>Algorithm</h3>
1715
1719
</ ol >
1716
1720
</ li >
1717
1721
< li > Initialize an empty < a class ="changed "> dictionary</ a > , < var > result</ var > .</ li >
1718
- < li id ="alg-expand-each-key-value "> For each < var > key</ var > and < var > value</ var > in < var > element</ var > ,
1722
+ < li id ="alg-expand-each-key-value ">
1723
+ < span class ="changed ">
1724
+ Initialize an empty < a > dictionary</ a > , < var > nests</ var > , and
1725
+ < var > input type</ var > to the last value of any < a > member</ a > expanding to < code > @type</ code > .
1726
+ </ span >
1727
+ For each < var > key</ var > and < var > value</ var > in < var > element</ var > ,
1719
1728
ordered lexicographically by < var > key</ var > < span class ="changed "> if < a data-link-for ="JsonLdOptions "> ordered</ a > is < code > true</ code > </ span > :
1720
1729
< ol >
1721
1730
< li > If < var > key</ var > is < code > @context</ code > , continue to
@@ -1778,7 +1787,11 @@ <h3>Algorithm</h3>
1778
1787
and < a data-link-for ="JsonLdOptions "> ordered</ a > flags</ span > ,
1779
1788
< span class ="changed ">
1780
1789
ensuring that < var > expanded value</ var > is an < a > array</ a > of one or more < a > dictionaries</ a > </ span > .</ li >
1781
- < li > If < var > expanded property</ var > is < code > @value</ code > and
1790
+ < li > Otherwise, if < var > expanded property</ var > is < code > @value</ code > ,
1791
+ < span class ="changed "> < a > processing mode</ a > is < code > json-ld-1.1</ code > , and
1792
+ < var > input type</ var > is < code > @json</ code > ,
1793
+ set < var > expanded value</ var > to < var > value</ var > .
1794
+ Otherwise, if</ span >
1782
1795
< var > value</ var > is not a < a > scalar</ a > or < code > null</ code > , an
1783
1796
< a data-link-for ="JsonLdErrorCode "> invalid value object value</ a >
1784
1797
error has been detected and processing is aborted. Otherwise,
@@ -1903,7 +1916,11 @@ <h3>Algorithm</h3>
1903
1916
set < var > term context</ var > to < var > active context</ var > .</ li >
1904
1917
< li > Set < var > container mapping</ var > to < var > key</ var > 's < a > container mapping</ a > in
1905
1918
< var class ="changed "> term context</ var > .</ li >
1906
- < li > If < var > container mapping</ var > < span class ="changed "> includes</ span > < code > @language</ code > and
1919
+ < li class ="changed "> If < var > key</ var > 's < a > term definition</ a > in < var > active context</ var >
1920
+ has a < a > type mapping</ a > of < code > @json</ code > ,
1921
+ set < var > expanded value</ var > to a new < a > dictionary</ a > the the < a > member</ a >
1922
+ < code > @value</ code > set to < var > value</ var > , and < code > @type</ code > set to < code > @json</ code > .</ li >
1923
+ < li > Otherwise, if < var > container mapping</ var > < span class ="changed "> includes</ span > < code > @language</ code > and
1907
1924
< var > value</ var > is a < a class ="changed "> dictionary</ a > then < var > value</ var >
1908
1925
is expanded from a < a > language map</ a >
1909
1926
as follows:
@@ -2077,7 +2094,7 @@ <h3>Algorithm</h3>
2077
2094
< var > nested value</ var > expands to < code > @value</ code > , an
2078
2095
< a data-link-for ="JsonLdErrorCode "> invalid @nest value</ a > error
2079
2096
has been detected and processing is aborted.</ li >
2080
- < li > Recursively repeat < a href ="#alg-expand-each-key-value "> step 7 </ a >
2097
+ < li > Recursively repeat < a href ="#alg-expand-each-key-value "> step 9 </ a >
2081
2098
using < var > nested value</ var > for < var > element</ var > .</ li >
2082
2099
</ ol >
2083
2100
</ li >
@@ -2096,6 +2113,9 @@ <h3>Algorithm</h3>
2096
2113
error has been detected and processing is aborted.</ li >
2097
2114
< li > If the value of < var > result</ var > 's < code > @value</ code > < a > member</ a > is
2098
2115
< code > null</ code > , then set < var > result</ var > to < code > null</ code > .</ li >
2116
+ < li class ="changed "> Otherwise, if the < var > result</ var > 's < code > @type</ code > < a > member</ a >
2117
+ is < code > @json</ code > , then the < code > @value</ code > < a > member</ a > may
2118
+ contain any value, and is treated as a < a > JSON literal</ a > .</ li >
2099
2119
< li > Otherwise, if the value of < var > result</ var > 's < code > @value</ code > < a > member</ a >
2100
2120
is not a < a > string</ a > and < var > result</ var > contains the < a > member</ a >
2101
2121
< code > @language</ code > , an
@@ -2220,7 +2240,7 @@ <h3>Algorithm</h3>
2220
2240
< var > value</ var > .</ li >
2221
2241
< li > If < var > active property</ var > has a < a > type mapping</ a > in
2222
2242
< var > active context</ var > ,
2223
- < span class ="changed "> other than < code > @id</ code > or < code > @vocab</ code > , or < code > @none</ code > ,</ span >
2243
+ < span class ="changed "> other than < code > @id</ code > , < code > @vocab</ code > , or < code > @none</ code > ,</ span >
2224
2244
add an < code > @type</ code > < a > member</ a > to
2225
2245
< var > result</ var > and set its value to the value associated with the
2226
2246
< a > type mapping</ a > .</ li >
@@ -2372,7 +2392,10 @@ <h3>Algorithm</h3>
2372
2392
< a href ="#value-compaction "> Value Compaction algorithm</ a > ,
2373
2393
passing < var > active context</ var > , < var > inverse context</ var > ,
2374
2394
< var > active property</ var > ,and < var > element</ var > as < var > value</ var > is
2375
- a < a > scalar</ a > , return that result.</ li >
2395
+ a < a > scalar</ a > ,
2396
+ < span class ="changed "> or the < a > term definition</ a > for < var > active property</ var >
2397
+ has a < a > type mapping</ a > of < code > @json</ code > ,</ span >
2398
+ return that result.</ li >
2376
2399
< li class ="changed "> If < var > element</ var > is a
2377
2400
< a > list object</ a > , and the < a > container mapping</ a > for
2378
2401
< var > active property</ var > in < var > active context</ var > is < code > @list</ code > ,
@@ -4235,6 +4258,13 @@ <h3>Algorithm</h3>
4235
4258
< li class ="changed "> If < var > datatype</ var > is not < a > well-formed</ a > , return < code > null</ code > .</ li >
4236
4259
< li class ="changed "> If < var > item</ var > has a < code > @language</ code >
4237
4260
< a > member</ a > which is not < a > well-formed</ a > , return < code > null</ code > .</ li >
4261
+ < li class ="changed "> If < var > datatype</ var > is < code > @json</ code > ,
4262
+ convert < var > value</ var > to the < a > canonical lexical form</ a > as defined in [[JCS]]
4263
+ using the result of transforming the < a > internal representation</ a > of < var > value</ var >
4264
+ to JSON and set < var > datatype</ var > to < code > jsonld:JSON</ code > .
4265
+ < div class ="issue atrisk "> JCS is still in draft form, and normatively requiring
4266
+ JSON canonicalization may be removed in a future draft, or
4267
+ a JSON-LD specific canonicalization form may be defined.</ div > </ li >
4238
4268
< li > If < var > value</ var > is < code > true</ code > or
4239
4269
< code > false</ code > , set < var > value</ var > to the < a > string</ a >
4240
4270
< code > true</ code > or < code > false</ code > which is the
@@ -4552,6 +4582,11 @@ <h3>Overview</h3>
4552
4582
< a > value objects</ a > whereas < a > IRIs</ a > and
4553
4583
< a > blank node identifiers</ a > are
4554
4584
transformed to < a > node objects</ a > .
4585
+ < span class ="changed "> Literals with datatype < code > jsonld:JSON</ code >
4586
+ are transformed into a value object using the internal representation
4587
+ based on the lexical-to-value mapping defined in
4588
+ < a data-cite ="JSON-LD11#dfn-json-datatype " class ="externalDfn "> JSON datatype</ a > in [[JSON-LD11]]</ span > ,
4589
+ and < code > @type</ code > of < code > @json</ code > .</ span >
4555
4590
If the < a data-link-for ="JsonLdOptions "> useNativeTypes</ a > flag is set to < code > true</ code > ,
4556
4591
< a > RDF literals</ a > with a
4557
4592
< a > datatype IRI</ a >
@@ -4610,6 +4645,11 @@ <h3>Algorithm</h3>
4610
4645
to a JSON < a > number</ a > .</ li >
4611
4646
</ ol >
4612
4647
</ li >
4648
+ < li class ="changed "> Otherwise, if < a > processing mode</ a > is < code > json-ld-1.1</ code > ,
4649
+ and < var > value</ var > is a < a > JSON literal</ a > ,
4650
+ set the < code > @value</ code > < a > member</ a > to the result of
4651
+ turning the lexical value of < var > value</ var >
4652
+ into the < a > JSON-LD internal representation</ a > , and set < var > type</ var > to < code > @json</ code > .</ li >
4613
4653
< li > Otherwise, if < var > value</ var > is a
4614
4654
< a > language-tagged string</ a >
4615
4655
add a < a > member</ a > < code > @language</ code > to < var > result</ var > and set its value to the
@@ -4638,9 +4678,10 @@ <h2>Data Round Tripping</h2>
4638
4678
or not (the result of a modulo‑1 operation), the boolean values
4639
4679
< code > true</ code > and < code > false</ code > are coerced to < code > xsd:boolean</ code > ,
4640
4680
and < a > strings</ a > are coerced to < code > xsd:string</ code > .
4641
- The numeric or boolean values themselves are converted to
4681
+ The JSON, numeric, or boolean values themselves are converted to
4642
4682
< dfn > canonical lexical form</ dfn > , i.e., a deterministic string
4643
- representation as defined in [[XMLSCHEMA11-2]].</ p >
4683
+ representation as defined in [[XMLSCHEMA11-2]]
4684
+ < span class ="changed "> and [[JCS]]</ span > .
4644
4685
4645
4686
< p > The < a > canonical lexical form</ a > of an < em > integer</ em > , i.e., a
4646
4687
< a > number</ a > with no non-zero fractional part or a < a > number</ a >
@@ -4692,6 +4733,56 @@ <h2>Data Round Tripping</h2>
4692
4733
values < code > true</ code > and < code > false</ code > are the strings
4693
4734
< code > true</ code > and < code > false</ code > .</ p >
4694
4735
4736
+ < p class ="changed "> The < a > canonical lexical form</ a > of the < a > JSON literal</ a >
4737
+ values are defined in [[JCS]]. The internal representation
4738
+ of value objects having @type @json are converted to JSON
4739
+ and canonicalized to reduce unnecessary whitespace,
4740
+ order object members, and use a standard representation
4741
+ for strings and numbers.</ p >
4742
+
4743
+ < aside class ="example changed " data-ignore
4744
+ title ="Canonicalized JSON literal ">
4745
+ < pre class ="original " data-transform ="updateExample ">
4746
+ <!--
4747
+ {
4748
+ "@context": {
4749
+ "@version": 1.1,
4750
+ "e": {"@id": "http://example.org/vocab#c14n", ****"@type": "@json"****}
4751
+ },
4752
+ "e": ****[
4753
+ 56.0,
4754
+ {
4755
+ "d": true,
4756
+ "10": null,
4757
+ "1": [ ]
4758
+ }
4759
+ ]****
4760
+ }
4761
+ -->
4762
+ </ pre >
4763
+
4764
+ < p > The example shows the value of "e" as a native JSON array including
4765
+ unnecssary whitespace, a number and an object. The result
4766
+ eliminates the whitespace, uses a canonical number representation,
4767
+ and reorders the object members lexicographically:</ p >
4768
+
4769
+ < pre class ="turtle "
4770
+ data-content-type ="text/turtle "
4771
+ data-result-for ="Canonicalized JSON literal-original "
4772
+ data-transform ="updateExample "
4773
+ data-to-rdf >
4774
+ <!--
4775
+ @prefix ex: <http://example.org/vocab#> .
4776
+ @prefix jsonld: <http://www.w3.org/ns/json-ld#> .
4777
+ [ex:c14n ****"""[56,{"1":[],"10":null,"d":true}]"""^^jsonld:JSON****] .
4778
+ -->
4779
+ </ pre >
4780
+ </ aside >
4781
+
4782
+ < p class ="issue atrisk "> JCS is still in draft form, and normatively requiring
4783
+ JSON canonicalization may be removed in a future draft, or
4784
+ a JSON-LD specific canonicalization form may be defined.</ p >
4785
+
4695
4786
< p > When JSON-native < a > numbers</ a > are deserialized
4696
4787
to RDF, lossless data round-tripping cannot be guaranteed, as rounding
4697
4788
errors might occur. When
@@ -5731,6 +5822,7 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
5731
5822
< li > Because scoped contexts can lead to contexts being reloaded, replace the
5732
5823
< strong > recursive context inclusion</ strong > error with a < a data-link-for ="JsonLdErrorCode "> context overflow</ a > error.</ li >
5733
5824
< li > Added support for < code > "@type": "@none"</ code > in a < a > term definition</ a > to prevent value compaction.</ li >
5825
+ < li > Added support for < a > JSON literals</ a > .</ li >
5734
5826
</ ul >
5735
5827
</ section >
5736
5828
0 commit comments