Add test case for strings in @graph [], update jsonld.js.
--- a/playground/jsonld.js Mon Apr 30 19:53:03 2012 -0400
+++ b/playground/jsonld.js Mon Apr 30 19:54:24 2012 -0400
@@ -423,6 +423,7 @@
*
* @param input the JSON-LD input.
* @param [options] the options to use:
+ * [base] the base IRI to use.
* [format] the format to use to output a string:
* 'application/nquads' for N-Quads (default).
* [resolver(url, callback(err, jsonCtx))] the URL resolver to use.
@@ -1817,6 +1818,10 @@
}
if(_isString(element)) {
+ // property can be null for string subject references in @graph
+ if(property === null) {
+ return;
+ }
// emit IRI for rdf:type, else plain literal
var statement = {
subject: _clone(subject),
@@ -1824,7 +1829,7 @@
object: {
nominalValue: element,
interfaceName: ((property.nominalValue === RDF_TYPE) ?
- 'IRI': 'LiteralNode')
+ 'IRI' : 'LiteralNode')
}
};
if(graph !== null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/toRdf-0030-in.jsonld Mon Apr 30 19:54:24 2012 -0400
@@ -0,0 +1,26 @@
+{
+ "@context": {
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
+ "knows": "http://xmlns.com/foaf/0.1/knows",
+ "name": "http://xmlns.com/foaf/0.1/name",
+ "asOf": "http://example.org/asOf"
+ },
+ "@id": "http://example.org/linked-data-graph",
+ "asOf": {"@value": "2012-04-09", "@type": "xsd:date"},
+ "@graph":
+ [
+ {
+ "@id": "http://manu.sporny.org/i/public",
+ "@type": "foaf:Person",
+ "name": "Manu Sporny",
+ "knows": "http://greggkellogg.net/foaf#me"
+ },
+ {
+ "@id": "http://greggkellogg.net/foaf#me",
+ "@type": "foaf:Person",
+ "name": "Gregg Kellogg",
+ "knows": "http://manu.sporny.org/i/public"
+ },
+ "http://www.markus-lanthaler.com/"
+ ]
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/toRdf-0030-out.nq Mon Apr 30 19:54:24 2012 -0400
@@ -0,0 +1,7 @@
+<http://manu.sporny.org/i/public> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <foaf:Person> <http://example.org/linked-data-graph> .
+<http://manu.sporny.org/i/public> <http://xmlns.com/foaf/0.1/knows> "http://greggkellogg.net/foaf#me" <http://example.org/linked-data-graph> .
+<http://manu.sporny.org/i/public> <http://xmlns.com/foaf/0.1/name> "Manu Sporny" <http://example.org/linked-data-graph> .
+<http://greggkellogg.net/foaf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <foaf:Person> <http://example.org/linked-data-graph> .
+<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/knows> "http://manu.sporny.org/i/public" <http://example.org/linked-data-graph> .
+<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" <http://example.org/linked-data-graph> .
+<http://example.org/linked-data-graph> <http://example.org/asOf> "2012-04-09"^^<http://www.w3.org/2001/XMLSchema#date> .
--- a/test-suite/tests/toRdf-manifest.jsonld Mon Apr 30 19:53:03 2012 -0400
+++ b/test-suite/tests/toRdf-manifest.jsonld Mon Apr 30 19:54:24 2012 -0400
@@ -179,6 +179,12 @@
"purpose": "Tests that named graphs containing named graphs flatten to single level of graph naming.",
"input": "toRdf-0029-in.jsonld",
"expect": "toRdf-0029-out.nq"
- }
+ }, {
+ "@type": ["test:TestCase", "jld:ToRDFTest"],
+ "name": "top-level graph with string subject reference",
+ "purpose": "Tests graphs containing subject references as strings.",
+ "input": "toRdf-0030-in.jsonld",
+ "expect": "toRdf-0030-out.nq"
+ }
]
}