Fix @type in turtle output.
authorDave Longley <dlongley@digitalbazaar.com>
Mon, 28 Nov 2011 23:19:57 -0500
changeset 281 df2a1d2d98c7
parent 280 c70c1b587b38
child 282 886cc8bb4fec
Fix @type in turtle output.
playground/jsonld-turtle.js
playground/jsonld.js
--- a/playground/jsonld-turtle.js	Mon Nov 28 23:13:35 2011 -0500
+++ b/playground/jsonld-turtle.js	Mon Nov 28 23:19:57 2011 -0500
@@ -10,7 +10,7 @@
 
 /**
  * Retrieves all of the properties that are a part of a JSON-LD object, 
- * ignoring the "@" special character.
+ * ignoring the "@subject" key.
  *
  * @param obj the JSON-LD object - the last part of the triple.
  *
@@ -20,7 +20,7 @@
 {
    var rval = [];
 
-   // accumulate the names of all non-JSON-LD special keys
+   // accumulate the names of all non-JSON-LD subjects
    for(var key in obj)
    {
       if(key != "@subject")
@@ -158,7 +158,15 @@
       {
          // serialize each property-object combination
          property = properties[p];
-         rval += "   <" + property + "> " + objectToString(subject[property]);
+         if(property == "@type")
+         {
+            rval += "   <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ";
+         }
+         else
+         {
+            rval += "   <" + property + "> ";
+         }
+         rval += objectToString(subject[property]);
 
          if(count == 1)
          {
--- a/playground/jsonld.js	Mon Nov 28 23:13:35 2011 -0500
+++ b/playground/jsonld.js	Mon Nov 28 23:19:57 2011 -0500
@@ -44,7 +44,6 @@
  */
 var ns =
 {
-   rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
    xsd: 'http://www.w3.org/2001/XMLSchema#'
 };