Skip to content

On parsing, @included section is ignored unless the JSON-LD document is flattened #98

@anatoly-scherbakov

Description

@anatoly-scherbakov

Disposition

Full code example is in this Gist.

I am trying to import a JSON-LD document into an RDFLib ConjunctiveGraph. The document:

{
    "@context": {
        "schema": "https://schema.org/",
        "blog": "https://blog.me/",
        "ex": "https://example.org/",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
    },
    "@id": "blog:JSONLD-and-named-graphs",
    "@type": "schema:blogPost",
    "rdfs:label": "JSON-LD and Named Graphs",
    "@included": [
        {
            "@id": "ex:Robot",
            "@type": "rdfs:Class"
        },
        {
            "@id": "ex:Rover",
            "rdfs:subClassOf": {
                "@id": "ex:Robot"
            }
        }
    ]
}

Notice it has an @included section.

Actual Result

The contents of the @included section is NOT imported, i.e. N3 serialization looks like this:

@prefix blog: <https://blog.me/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .

blog:JSONLD-and-named-graphs a schema:blogPost ;
    rdfs:label "JSON-LD and Named Graphs" .

...Unless

... I do jsonld.flatten() before importing, in which case everything works:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://example.org/Robot> a rdfs:Class .

<https://blog.me/JSONLD-and-named-graphs> a <https://schema.org/blogPost> ;
    rdfs:label "JSON-LD and Named Graphs" .

<https://example.org/Rover> rdfs:subClassOf <https://example.org/Robot> .

Is this expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions