Add example illustrating round-tripping of native data types
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Wed, 13 Mar 2013 17:34:00 +0100
changeset 1432 1844d1dce747
parent 1431 4dd1523a68b3
child 1433 c6b5263ce7f7
Add example illustrating round-tripping of native data types

This addresses #224.
spec/latest/json-ld-syntax/index.html
--- a/spec/latest/json-ld-syntax/index.html	Wed Mar 13 17:08:51 2013 +0100
+++ b/spec/latest/json-ld-syntax/index.html	Wed Mar 13 17:34:00 2013 +0100
@@ -3091,6 +3091,49 @@
     </section>
 
     <section>
+      <h4>Conversion of native data types</h4>
+
+      <p>In JSON-LD numbers and boolean values are native data types. While Turtle
+        has a shorthand syntax to express such values, RDF's abstract syntax requires
+        that numbers and boolean values are represented as typed literals. Thus,
+        to allow full round-tripping, the JSON-LD Processing Algorithms and API specification [[JSON-LD-API]]
+        defines conversion rules between JSON-LD's native data types and RDF's
+        counterparts. <tref title="number">Numbers</tref> without fractions are
+        converted to <code>xsd:integer</code>-typed literals, numbers with fractions
+        to <code>xsd:double</code>-typed literals and the two boolean values
+        <tref>true</tref> and <tref>false</tref> to a <code>xsd:boolean</code>-typed
+        literal. All typed literals are in canonical lexical form.</p>
+
+      <pre class="example" data-transform="updateExample"
+           title="JSON-LD using native data types for numbers and boolean values">
+      <!--
+      {
+        "@context":
+        {
+          "ex": "http://example.com/vocab#"
+        },
+        "@id": "http://example.com/",
+        "ex:numbers": [ 14, 2.78 ],
+        "ex:booleans": [ true, false ]
+      }
+      -->
+      </pre>
+
+      <pre class="example" data-transform="updateExample"
+           title="Same example in Turtle using typed literals">
+      <!--
+      @prefix ex: <http://example.com/vocab#> .
+      @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+      <http://example.com/>
+        ex:numbers "14"^^xsd:integer, "2.78E0"^^xsd:double ;
+        ex:booleans "true"^^xsd:boolean, "false"^^xsd:boolean .
+      -->
+      </pre>
+
+    </section>
+
+    <section>
       <h4>Lists</h4>
       <p>Both JSON-LD and Turtle can represent sequential lists of values.</p>