You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Adam Jacobs <ja...@hotmail.com> on 2018/01/04 03:34:06 UTC

JsonLD @vocab

The @vocab prefix is dropped by Jena when parsing JsonLD.
An empty prefix is correctly translated into @vocab during serialization, but is lost during deserialization.
Below code demonstrates the point.

    public static void main(String... args) {
        String base = "http://www.ns.com/base/";
        String prefix = "http://www.ns.com/prefix/";

        Model m = ModelFactory.createDefaultModel();
        m.setNsPrefix("", base);
        m.setNsPrefix("prefix", prefix);

        m.add(m.createResource(base + "foo"), m.createProperty(prefix + "bar"), m.createResource(base + "baz"));
        String jsonLD = serializeJsonLD(m);
        System.out.println(jsonLD);

        InputStream in = new ByteArrayInputStream(jsonLD.getBytes());
        Model m2 = ModelFactory.createDefaultModel().read(in, null, "jsonld");
        System.out.println(serializeJsonLD(m2));
    }

    public static String serializeJsonLD(Model m) {
        OutputStream out = new ByteArrayOutputStream();
        m.write(out, "jsonld");
        return out.toString();
    }

From what I can see, jsonld-java is intentionally ignoring the @vocab key at line 277 of Context.java.
    https://github.com/jsonld-java/jsonld-java/blob/master/core/src/main/java/com/github/jsonldjava/core/Context.java

I'm not sure if this is a bug in jsonld-java, or intentional behavior from a jsonld perspective that Jena should work around e.g. in JsonLDReader?

Re: JsonLD @vocab

Posted by Andy Seaborne <an...@apache.org>.
https://github.com/jsonld-java/jsonld-java/issues

or for general JSON-LD:

public-linked-json@w3.org

     Andy

On 08/01/18 01:17, Adam Jacobs wrote:
> Do you know where jsonld discussions are at?
> I'm having trouble finding a mailing list.
> 
> 
> ________________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Thursday, January 4, 2018 2:34 PM
> To: dev@jena.apache.org
> Subject: Re: JsonLD @vocab
> 
> Adam,
> 
> In the first instance, this seems like something to raise with the
> jsonld-java team to find out if that is intentional. Could you open a
> discussion issue there?
> 
> IIRC empty prefix and the base are mixed up in JSON-LD.
> 
>       Andy
> 
> On 04/01/18 03:34, Adam Jacobs wrote:
>> The @vocab prefix is dropped by Jena when parsing JsonLD.
>> An empty prefix is correctly translated into @vocab during serialization, but is lost during deserialization.
>> Below code demonstrates the point.
>>
>>       public static void main(String... args) {
>>           String base = "http://www.ns.com/base/";
>>           String prefix = "http://www.ns.com/prefix/";
>>
>>           Model m = ModelFactory.createDefaultModel();
>>           m.setNsPrefix("", base);
>>           m.setNsPrefix("prefix", prefix);
>>
>>           m.add(m.createResource(base + "foo"), m.createProperty(prefix + "bar"), m.createResource(base + "baz"));
>>           String jsonLD = serializeJsonLD(m);
>>           System.out.println(jsonLD);
>>
>>           InputStream in = new ByteArrayInputStream(jsonLD.getBytes());
>>           Model m2 = ModelFactory.createDefaultModel().read(in, null, "jsonld");
>>           System.out.println(serializeJsonLD(m2));
>>       }
>>
>>       public static String serializeJsonLD(Model m) {
>>           OutputStream out = new ByteArrayOutputStream();
>>           m.write(out, "jsonld");
>>           return out.toString();
>>       }
>>
>>   From what I can see, jsonld-java is intentionally ignoring the @vocab key at line 277 of Context.java.
>>       https://github.com/jsonld-java/jsonld-java/blob/master/core/src/main/java/com/github/jsonldjava/core/Context.java
>>
>> I'm not sure if this is a bug in jsonld-java, or intentional behavior from a jsonld perspective that Jena should work around e.g. in JsonLDReader?
>>

Re: JsonLD @vocab

Posted by Adam Jacobs <ja...@hotmail.com>.
Do you know where jsonld discussions are at?
I'm having trouble finding a mailing list.


________________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Thursday, January 4, 2018 2:34 PM
To: dev@jena.apache.org
Subject: Re: JsonLD @vocab

Adam,

In the first instance, this seems like something to raise with the
jsonld-java team to find out if that is intentional. Could you open a
discussion issue there?

IIRC empty prefix and the base are mixed up in JSON-LD.

     Andy

On 04/01/18 03:34, Adam Jacobs wrote:
> The @vocab prefix is dropped by Jena when parsing JsonLD.
> An empty prefix is correctly translated into @vocab during serialization, but is lost during deserialization.
> Below code demonstrates the point.
>
>      public static void main(String... args) {
>          String base = "http://www.ns.com/base/";
>          String prefix = "http://www.ns.com/prefix/";
>
>          Model m = ModelFactory.createDefaultModel();
>          m.setNsPrefix("", base);
>          m.setNsPrefix("prefix", prefix);
>
>          m.add(m.createResource(base + "foo"), m.createProperty(prefix + "bar"), m.createResource(base + "baz"));
>          String jsonLD = serializeJsonLD(m);
>          System.out.println(jsonLD);
>
>          InputStream in = new ByteArrayInputStream(jsonLD.getBytes());
>          Model m2 = ModelFactory.createDefaultModel().read(in, null, "jsonld");
>          System.out.println(serializeJsonLD(m2));
>      }
>
>      public static String serializeJsonLD(Model m) {
>          OutputStream out = new ByteArrayOutputStream();
>          m.write(out, "jsonld");
>          return out.toString();
>      }
>
>  From what I can see, jsonld-java is intentionally ignoring the @vocab key at line 277 of Context.java.
>      https://github.com/jsonld-java/jsonld-java/blob/master/core/src/main/java/com/github/jsonldjava/core/Context.java
>
> I'm not sure if this is a bug in jsonld-java, or intentional behavior from a jsonld perspective that Jena should work around e.g. in JsonLDReader?
>

Re: JsonLD @vocab

Posted by Andy Seaborne <an...@apache.org>.
Adam,

In the first instance, this seems like something to raise with the 
jsonld-java team to find out if that is intentional. Could you open a 
discussion issue there?

IIRC empty prefix and the base are mixed up in JSON-LD.

     Andy

On 04/01/18 03:34, Adam Jacobs wrote:
> The @vocab prefix is dropped by Jena when parsing JsonLD.
> An empty prefix is correctly translated into @vocab during serialization, but is lost during deserialization.
> Below code demonstrates the point.
> 
>      public static void main(String... args) {
>          String base = "http://www.ns.com/base/";
>          String prefix = "http://www.ns.com/prefix/";
> 
>          Model m = ModelFactory.createDefaultModel();
>          m.setNsPrefix("", base);
>          m.setNsPrefix("prefix", prefix);
> 
>          m.add(m.createResource(base + "foo"), m.createProperty(prefix + "bar"), m.createResource(base + "baz"));
>          String jsonLD = serializeJsonLD(m);
>          System.out.println(jsonLD);
> 
>          InputStream in = new ByteArrayInputStream(jsonLD.getBytes());
>          Model m2 = ModelFactory.createDefaultModel().read(in, null, "jsonld");
>          System.out.println(serializeJsonLD(m2));
>      }
> 
>      public static String serializeJsonLD(Model m) {
>          OutputStream out = new ByteArrayOutputStream();
>          m.write(out, "jsonld");
>          return out.toString();
>      }
> 
>  From what I can see, jsonld-java is intentionally ignoring the @vocab key at line 277 of Context.java.
>      https://github.com/jsonld-java/jsonld-java/blob/master/core/src/main/java/com/github/jsonldjava/core/Context.java
> 
> I'm not sure if this is a bug in jsonld-java, or intentional behavior from a jsonld perspective that Jena should work around e.g. in JsonLDReader?
>