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

A list of '@id' #2

Closed
cardinal27513 opened this issue Apr 6, 2012 · 1 comment
Closed

A list of '@id' #2

cardinal27513 opened this issue Apr 6, 2012 · 1 comment

Comments

@cardinal27513
Copy link

We use rdflib a while and used to serialize data to rdf/xml. There are multiple toplevel graphs in our data, like it is shown in below. There are two "<rdf:Description rdf:about=…/>" in the data set…

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:ns1="http://example.com/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
  <rdf:Description rdf:about="http://example.com/3">
    <rdf:type rdf:resource="http://example.com/ns#Verb_A"/>
    <ns1:hasChild rdf:resource="http://example.com/4"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://example.com/1">
    <rdf:type rdf:resource="http://example.com/ns#Verb_A"/>
    <ns1:hasChild rdf:resource="http://example.com/2"/>
  </rdf:Description>
</rdf:RDF>

When we try to serialize the same graph to json-ld using rdflib-jsonld serializer, the top-level graphs are serialized as “@id” : [ {…} , {…}]
I try this out from the jsonld playground http://json-ld.org/playground/ and it complains that there is syntax error.
{"name":"jsonld.CompactError","message":"Could not expand input before compaction.","details":{"cause":{"name":"jsonld.SyntaxError","message":"Invalid JSON-LD syntax; "@id" value must a string.","details":{}}}}
So is this the bug in jsonld.js or the rdflib-jsonld ?

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
  },
  "@id": [
    {
      "@id": "http://example.com/3",
      "@type": "http://example.com/ns#Verb_A",
      "http://example.com/ns#hasChild": {
        "@id": "http://example.com/4"
      }
    },
    {
      "@id": "http://example.com/1",
      "@type": "http://example.com/ns#Verb_A",
      "http://example.com/ns#hasChild": {
        "@id": "http://example.com/2"
      }
    }
  ]
}
@cardinal27513
Copy link
Author

Hi Graham,
Just found out that need to replace "@id" with "@graph" at the top level.. that is the new syntax...

digitalbazaar/jsonld.js#9

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

2 participants