[
https://issues.apache.org/jira/browse/JENA-1031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14956475#comment-14956475
]
Andy Seaborne commented on JENA-1031:
-------------------------------------
Is your point that using the short form or long form should result in the same
RDF? Do you have a reference to the part of the JSON-LD specification that
states that?
Editing the JSON as JSON must respect the additional constraints that JSON-LD
imposed on JSON and also the {{@context}}. Arbitrary editing of the JSON may
break the RDF triples.
Jena uses the [jsonld-java|https://github.com/jsonld-java/jsonld-java] package
for reading and writing JSON-LD.
I also tested with the [JSON LD Playground|http://json-ld.org/playground/] test
site which is a completely different implementation and get the same two
different outputs.
You can write the JSON-LD context to declare the datatype of the long URL as:
{noformat}
{
"@id" : "http://example.com/a",
"http://example.com/ontology#generated_at": "2015-10-13",
"generated_at": "2015-10-14",
"@context" : {
"http://example.com/ontology#generated_at" : {
"@type" : "http://www.w3.org/2001/XMLSchema#date"
}
}
}
{noformat}
and indeed it can include both forms:
{noformat}
{
"@id" : "http://example.com/a",
"http://example.com/ontology#generated_at": "2015-10-13",
"generated_at": "2015-10-14",
"@context" : {
"http://example.com/ontology#generated_at" : {
"@type" : "http://www.w3.org/2001/XMLSchema#date"
} ,
"generated_at" : {
"@id" : "http://example.com/ontology#generated_at",
"@type" : "http://www.w3.org/2001/XMLSchema#date"
}
}
}
{noformat}
> Aliases for data properties not used
> ------------------------------------
>
> Key: JENA-1031
> URL: https://issues.apache.org/jira/browse/JENA-1031
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 3.0.0
> Environment: Ubuntu 14.04 64bit, IntelliJ IDEA, JDK 8
> Reporter: Gert van Valkenhoef
> Assignee: Andy Seaborne
> Priority: Minor
>
> When JSON-LD is generated for a graph, the @context will contain property
> aliases for all properties used in the graph. However, for properties that
> have a data value (rather than a resource), these aliases are not used, and
> the properties in the @graph are still their full URIs. This is harmful when
> the @context also specifies a data type. For example, doubles can be
> converted to integer by accident. The example turtle below results in JSON-LD
> that when parsed by Jena is not isomorphic with the graph parsed from turtle
> (because the doubleValuedProperty will get an integer value):
> {code:title=test.ttl}
> <a> <http://www.w3.org/2000/01/rdf-schema#label> "b".
> <a> <http://example.com/ontology#doubleValuedProperty> 3.0e1 .
> {code}
> The JSON-LD as output by Jena:
> {code:javascript}
> {
> "@id" : "http://example.com/a",
> "http://example.com/ontology#doubleValuedProperty" : 30.0,
> "http://www.w3.org/2000/01/rdf-schema#label" : "b",
> "@context" : {
> "doubleValuedProperty" : {
> "@id" : "http://example.com/ontology#doubleValuedProperty",
> "@type" : "http://www.w3.org/2001/XMLSchema#double"
> },
> "label" : {
> "@id" : "http://www.w3.org/2000/01/rdf-schema#label",
> "@type" : "http://www.w3.org/2001/XMLSchema#string"
> }
> }
> }
> {code}
> A failing unit test for round-trip through JSON-LD:
> {code:java}
> @Test
> public void jenaBugTest() throws IOException {
> Model model = ModelFactory.createDefaultModel();
> model.read(new FileReader("test.ttl"), "http://example.com",
> RDFLanguages.strLangTurtle);
> StringWriter writer = new StringWriter();
> RDFDataMgr.write(writer, model, RDFLanguages.JSONLD);
> writer.close();
> System.out.println(writer.toString());
> Model model2 = ModelFactory.createDefaultModel();
> model2.read(new StringReader(writer.toString()), "http://example.com",
> RDFLanguages.strLangJSONLD);
> assertTrue(model.isIsomorphicWith(model2));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)