Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compacting RDF lists with @list leaves RDF vocabulary in JSON-LD #148

Open
sklarman opened this issue Feb 18, 2021 · 0 comments
Open

Compacting RDF lists with @list leaves RDF vocabulary in JSON-LD #148

sklarman opened this issue Feb 18, 2021 · 0 comments

Comments

@sklarman
Copy link

sklarman commented Feb 18, 2021

Not sure if it's a feature or a bug, but at least my intuitive expectation is not met in the following round-trip conversion involving @list:

Initial document:

{
    "@context": {
        "@vocab": "http://example.com/",
        "myList": {
            "@container": "@list"
        }
    },
    "@graph": [
        {
            "myList": ["a"]
        }
    ]
}

Converted to N-Quads:

_:b0 <http://example.com/myList> _:b1 .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "a" .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .

Back to expanded JSON-LD (e.g. with https://www.easyrdf.org/converter):

[
    {
        "http://example.com/myList": [
            {
                "@id": "_:b1"
            }
        ]
    },
    {
        "@id": "_:b1",
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": [
            {
                "@value": "a"
            }
        ],
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": [
            {
                "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
            }
        ]
    },
    {
        "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
    }
]

And then back to compacted JSON-LD with the initial context:

{
  "@context": {
    "@vocab": "http://example.com/",
    "myList": {
      "@container": "@list"
    }
  },
  "@graph": [
    {
      "http://example.com/myList": {
        "@id": "_:b1"
      }
    },
    {
      "@id": "_:b1",
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": "a",
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": {
        "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
      }
    }
  ]
}

In this last step I would expect to get the initial document again (or in any case one without explicit RDF vocabulary in it), which is the behavior I observed in most analogous cases. Note also that the key http://example.com/myList didn't get abbreviated as it normally would was it not for the @list container directive.

Could you please help me clarify if this looks ok to you or I am perhaps missing something? Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant