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

Andy Seaborne edited comment on JENA-2016 at 12/16/20, 5:10 PM:
----------------------------------------------------------------

Example using JSON_LD (v0.13.2) only

Data:
{noformat}
 {
    "@context": {
        "@base": "http://example.org/";,
        "tag:p": { "@type": "@id" }
    },
    "tag:p": [ "foo", 42, false ]
}
{noformat}

 Code:
{noformat}
 String FN = "D.jsonld";
 InputStream inputStream = new FileInputStream(FN);
 Object jsonObject = JsonUtils.fromInputStream(inputStream);
 Object x = JsonLdProcessor.toRDF(jsonObject);
 System.out.println(JsonUtils.toPrettyString(x));
{noformat}
gives
{noformat}
...
    "object" : {
      "type" : "IRI",
      "value" : "http://example.org/42";
    }
...
{noformat}


was (Author: andy.seaborne):
Example using JSON_LD (v0.13.2) only
{noformat}
 String FN = "D.jsonld"; // version with @base
 InputStream inputStream = new FileInputStream(FN);
 Object jsonObject = JsonUtils.fromInputStream(inputStream);
 Object x = JsonLdProcessor.toRDF(jsonObject);
 System.out.println(JsonUtils.toPrettyString(x));
{noformat}
gives
{noformat}
...
    "object" : {
      "type" : "IRI",
      "value" : "http://example.org/42";
    }
...
{noformat}

> JSON-LD expand problem with `"@type": "@id"`
> --------------------------------------------
>
>                 Key: JENA-2016
>                 URL: https://issues.apache.org/jira/browse/JENA-2016
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: RIOT
>    Affects Versions: Jena 3.16.0, Jena 3.17.0
>            Reporter: Pierre-Antoine Champin
>            Priority: Major
>
>  
> The following JSON-LD
>  
> {code:java}
> {
>  "@context": {
>      "tag:p": { "@type": "@id" }
>  },
>  "tag:p": [ "foo", 42, false ]
> }{code}
>  
> [ Update - see comment:]
> {code:java}
> {
>  "@context": {
>      "@base": "http://example.org/";,
>      "tag:p": { "@type": "@id" }
>  },
>  "tag:p": [ "foo", 42, false ]
> }{code}
>  
> generates the following triples
>  
> {code:java}
> _:b0 <tag:p> <file:///tmp/foo> .
> _:b0 <tag:p> <file:///tmp/42> .
> _:b0 <tag:p> <file:///tmp/false> . 
> {code}
> while it should generate
>  
> {code:java}
> _:b0 <tag:p> <file:///tmp/foo> .
> _:b0 <tag:p> "42"^^<http://www.w3.org/2001/XMLSchema#integer> .
> _:b0 <tag:p> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
> {code}
> Indeed, step 1 for the [value expansion 
> algorithm|https://w3c.github.io/json-ld-api/#algorithm-5] states that the 
> type mapping to `@id` is only considered if the value is a string.
> See for example in the JSON-LD playground: 
> [https://json-ld.org/playground/#startTab=tab-nquads&json-ld=%7B%22%40context%22%3A%7B%22tag%3Ap%22%3A%7B%22%40type%22%3A%22%40id%22%7D%7D%2C%22tag%3Ap%22%3A%5B%22foo%22%2C42%2Cfalse%5D%7D]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to