Skip to content

In conversion jsonld to rdf some data are missing. #232

Closed

Description

@giatrakister

Hi,

i use jsonld java to convert jsonld data to rdf. My jsonld data are like that:

jsonld.txt

and the code i used for the conversion is:

         InputStream inputStream = new FileInputStream("C:\\Users\\Desktop\\jsonLD.json");
        Object jsonObject = JsonUtils.fromInputStream(inputStream);
         Map context = new HashMap();
         JsonLdOptions options = new JsonLdOptions();
        Object myRdf = JsonLdProcessor.toRDF(jsonObject, options);

but the results does not include all the data, only the nested ones and the rdf format is not as expected:
resultsRDF.txt

Is there any intermediate step that i should follow?

thanx!

Activity

  1. giatrakister commented on Apr 20, 2018

    @giatrakister
    Author

    I think that the jsonld is not correct. My starting point is a json file, are there any guidelines for json to jsonld convertion?

  2. ansell commented on Apr 27, 2018

    @ansell
    Member

    Hi @giatrakister, those files are too large to investigate. Can you submit a smaller test file that shows where it may be breaking?

    In terms of a json to jsonld conversion question, you could ask on the JSON-LD mailing lists for assistance.

  3. vcharpenay commented on Oct 4, 2018

    @vcharpenay

    I ran into the same problem and I noticed that only objects with @id defined as relative IRIs with no @base disappear, as follows:

    Object o = JsonUtils.fromString("{\"@id\":\"relativeURIWithNoBase\",\"@type\":\"http://example.org/SomeRDFSClass\"}");
    System.out.println(JsonLdProcessor.toRDF(o));
    
    // expected: {@default=[{subject={type=IRI, value=./relativeURIWithNoBase}, predicate={type=IRI, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type}, object={type=IRI, value=http://example.org/SomeRDFSClass}}]}
    // actual:   {@default=[]}

    The section on RDF serialization mentions well-formed IRIs, which relative IRIs without base are not. @giatrakister, passing a base IRI as JSON-LD option will probably work, as follows:

    Object o = JsonUtils.fromString("{\"@id\":\"relativeURIWithNoBase\",\"@type\":\"http://example.org/SomeRDFSClass\"}");
    System.out.println(JsonLdProcessor.toRDF(o, new JsonLdOptions("http://example.org/")));
    
    // output: {@default=[{subject={type=IRI, value=http://example.org/relativeURIWithNoBase}, predicate={type=IRI, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type}, object={type=IRI, value=http://example.org/SomeRDFSClass}}]}

    However, @ansell, it seems there is another bug in my case: the base IRI argument is ignored if it uses an exotic URI scheme, like tag:. The following also returns an empty graph:

    Object o = JsonUtils.fromString("{\"@id\":\"relativeURIWithNoBase\",\"@type\":\"http://example.org/SomeRDFSClass\"}");
    System.out.println(JsonLdProcessor.toRDF(o, new JsonLdOptions("tag:example/")));
    
    // expected: {@default=[{subject={type=IRI, value=tag:example/relativeURIWithNoBase}, predicate={type=IRI, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type}, object={type=IRI, value=http://example.org/SomeRDFSClass}}]}
    // actual:   {@default=[]}
  4. fsteeg commented on May 17, 2019

    @fsteeg
    Member

    [...] another bug in my case: the base IRI argument is ignored if it uses an exotic URI scheme, like tag:

    I took a look at this and it seems the problem here is not the scheme itself, but the fact that the base IRI is opaque (not hierarchical), meaning the scheme-specific part does not start with a slash. With new JsonLdOptions("tag:/example/") I do get the expected output.

    And while that works, it seems the hierarchical part should actually start with two slashes, see https://w3c.github.io/json-ld-syntax/#base-iri, https://tools.ietf.org/html/rfc3986#section-5.1, https://tools.ietf.org/html/rfc3986#section-4.3, and https://tools.ietf.org/html/rfc3986#appendix-A

    Edit: I read the RFC wrong, see https://tools.ietf.org/html/rfc3986#section-5.1, which links to https://tools.ietf.org/html/rfc3986#section-4.3, where hier-part is mentioned, which can have a path-rootless (see https://tools.ietf.org/html/rfc3986#appendix-A), which used to be called the opaque_part (see https://tools.ietf.org/html/rfc3986#appendix-D.2). So while the workaround described above works, not resolving correctly with the opaque base URI is actually a bug.

  5. fsteeg commented on Jun 27, 2019

    @fsteeg
    Member

    Fixed in master, closing. See #260.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions