Create nodes for IRIs and blank nodes in object position when converting from RDF
The same happens when flattening.
/cc @dlongley @gkellog (this was the controversial change I was talking about)
--- a/spec/latest/json-ld-api/index.html Sun May 05 20:58:56 2013 +0200
+++ b/spec/latest/json-ld-api/index.html Sun May 05 21:15:27 2013 +0200
@@ -3397,6 +3397,12 @@
set to <i>subject</i>.</li>
<li>Reference the value of the <i>subject</i> member in <i>node map</i>
using the variable <i>node</i>.</li>
+ <li>If <i>object</i> is an <tref>IRI</tref> or
+ <tref>blank node identifier</tref>, does not equal <code>rdf:nil</code>,
+ and <i>node map</i> does not have an <i>object</i> member,
+ create one and initialize its value to a new <tref>JSON object</tref>
+ consisting of a single member <code>@id</code> whose value is
+ set to <i>object</i>.</li>
<li>If <i>predicate</i> equals <code>rdf:type</code>, and <i>object</i>
is an <tref>IRI</tref> or <tref>blank node identifier</tref>,
append <i>object</i> to the value of the <code>@type</code>
@@ -3420,10 +3426,6 @@
<i>predicate</i> equals neither <code>rdf:first</code> nor
<code>rdf:rest</code>, it might represent the head of a RDF list:
<ol class="algorithm">
- <li>If <i>node map</i> does not have an <i>object</i> member,
- create one and initialize its value to a new <tref>JSON object</tref>
- consisting of a single member <code>@id</code> whose value is
- set to <i>object</i>.</li>
<li>If the <i>object</i> member of <i>node map</i> has an
<code>usages</code> member, add a reference to <i>value</i> to it;
otherwise create such a member and set its value to an
--- a/test-suite/tests/fromRdf-0001-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0001-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -1,10 +1,18 @@
-[{
- "@id": "http://example.com/Subj1",
- "@type": ["http://example.com/Type"],
- "http://example.com/prop1": [{"@id": "http://example.com/Obj1"}],
- "http://example.com/prop2": [
- {"@value": "Plain"},
- {"@value": "2012-05-12", "@type": "http://www.w3.org/2001/XMLSchema#date"},
- {"@value": "English", "@language": "en"}
- ]
-}]
\ No newline at end of file
+[
+ {
+ "@id": "http://example.com/Obj1"
+ },
+ {
+ "@id": "http://example.com/Subj1",
+ "@type": ["http://example.com/Type"],
+ "http://example.com/prop1": [{"@id": "http://example.com/Obj1"}],
+ "http://example.com/prop2": [
+ {"@value": "Plain"},
+ {"@value": "2012-05-12", "@type": "http://www.w3.org/2001/XMLSchema#date"},
+ {"@value": "English", "@language": "en"}
+ ]
+ },
+ {
+ "@id": "http://example.com/Type"
+ }
+]
--- a/test-suite/tests/fromRdf-0003-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0003-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -4,6 +4,9 @@
"@type": ["http://example.com/SubType"]
},
{
+ "@id": "http://example.com/SubType"
+ },
+ {
"@id": "http://example.com/Subj1",
"@type": ["http://example.com/Type"],
"http://example.com/ref": [
@@ -15,5 +18,8 @@
"@id": "http://example.com/Subj2",
"@type": ["http://example.com/Type"],
"http://example.com/ref": [{"@id": "http://example.com/Subj1"}]
+ },
+ {
+ "@id": "http://example.com/Type"
}
-]
\ No newline at end of file
+]
--- a/test-suite/tests/fromRdf-0004-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0004-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -1,16 +1,24 @@
-[{
- "@id": "http://example.com/Subj1",
- "@type": ["http://example.com/Type"],
- "http://example.com/literalList": [{
- "@list": [
- {"@value": "apple"},
- {"@value": "bananna"}
- ]
- }],
- "http://example.com/emptyList": [{
- "@list": []
- }],
- "http://example.com/iriList": [{
- "@list": [{"@id": "http://example.com/iri"}]
- }]
-}]
\ No newline at end of file
+[
+ {
+ "@id": "http://example.com/Subj1",
+ "@type": ["http://example.com/Type"],
+ "http://example.com/literalList": [{
+ "@list": [
+ {"@value": "apple"},
+ {"@value": "bananna"}
+ ]
+ }],
+ "http://example.com/emptyList": [{
+ "@list": []
+ }],
+ "http://example.com/iriList": [{
+ "@list": [{"@id": "http://example.com/iri"}]
+ }]
+ },
+ {
+ "@id": "http://example.com/Type"
+ },
+ {
+ "@id": "http://example.com/iri"
+ }
+]
--- a/test-suite/tests/fromRdf-0005-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0005-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -1,18 +1,29 @@
-[{
- "@id": "http://example.com/U",
- "@graph": [
- {
- "@id": "http://example.com/Subj1",
- "@type": ["http://example.com/Type"],
- "http://example.com/ref": [{"@id": "http://example.com/U"}],
- "http://example.com/list": [{
- "@list": [
- {"@value": "a"},
- {"@value": "b"}
- ]
- }]
- }
- ],
- "@type": ["http://example.com/Graph"],
- "http://example.com/name": [{"@value": "Graph"}]
-}]
\ No newline at end of file
+[
+ {
+ "@id": "http://example.com/Graph"
+ },
+ {
+ "@id": "http://example.com/U",
+ "@graph": [
+ {
+ "@id": "http://example.com/Subj1",
+ "@type": ["http://example.com/Type"],
+ "http://example.com/ref": [{"@id": "http://example.com/U"}],
+ "http://example.com/list": [{
+ "@list": [
+ {"@value": "a"},
+ {"@value": "b"}
+ ]
+ }]
+ },
+ {
+ "@id": "http://example.com/Type"
+ },
+ {
+ "@id": "http://example.com/U"
+ }
+ ],
+ "@type": ["http://example.com/Graph"],
+ "http://example.com/name": [{"@value": "Graph"}]
+ }
+]
--- a/test-suite/tests/fromRdf-0006-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0006-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -12,6 +12,12 @@
{"@value": "b"}
]
}]
+ },
+ {
+ "@id": "http://example.com/Type"
+ },
+ {
+ "@id": "http://example.com/U"
}
]
},
@@ -28,7 +34,13 @@
{"@value": "d"}
]
}]
+ },
+ {
+ "@id": "http://example.com/Type2"
+ },
+ {
+ "@id": "http://example.com/V"
}
]
}
-]
\ No newline at end of file
+]
--- a/test-suite/tests/fromRdf-0007-out.jsonld Sun May 05 20:58:56 2013 +0200
+++ b/test-suite/tests/fromRdf-0007-out.jsonld Sun May 05 21:15:27 2013 +0200
@@ -9,6 +9,9 @@
"@id": "http://data.wikipedia.org/snaks/BerlinFact",
"@type": ["http://data.wikipedia.org/vocab#Snak"],
"http://data.wikipedia.org/vocab#assertedBy": [{"@value": "http://www.statistik-berlin-brandenburg.de/"}]
+ },
+ {
+ "@id": "http://data.wikipedia.org/vocab#Snak"
}
]
},
@@ -22,5 +25,8 @@
}]
}
]
+ },
+ {
+ "@id": "http://data.wikipedia.org/vocab#SnakSet"
}
]