[ 
https://issues.apache.org/jira/browse/JENA-1031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14956520#comment-14956520
 ] 

Gert van Valkenhoef commented on JENA-1031:
-------------------------------------------

No that is not my point, I agree that the way the JSON-LD is being parsed is 
correct, and that both JSON-LD documents in my previous example should result 
in two different RDF graphs.

My point is that the JSON-LD that is being generated by Jena is sub-optimal, 
because aliases are being generated for predicates with literal values that 
contain type information, but those aliases are not used, and this results in 
the loss of the type information. My examples were just to demonstrate that one 
easily encounters this problem in practice (as my first example already showed 
that the aliases are not used).

Perhaps I should report this issue to jsonld-java instead?

> 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)

Reply via email to