w3c / json-ld-api

JSON-LD 1.1 Processing Algorithms and API Specification
https://w3c.github.io/json-ld-api/
Other
76 stars 29 forks source link

Define a top-level @container as @type? #526

Closed davidbarratt closed 3 years ago

davidbarratt commented 3 years ago

If I have an object like this:

{
  "@context": "https://schema.org",
  "Person":  [
     {
       "name": "David"
     }
  ],
  "Country" : [
      {
        "code": "US"
      }
   ]
}

Is there a way to describe that this is a type map at the top level? I couldn't find a way to do this and the playground screams at me for attempting to override a keyword.

gkellogg commented 3 years ago

No; type maps are associated with terms, so you would need a top-level property who's values were the types. Something like the following:

{
  "@context": ["https://schema.org", {
    "types": {"@id": "ex:types", "@container": "@type"}
  }],
  "types": {
    "Person":  [{"name": "David"}],
    "Country" : [{"code": "US"}]
  }
}
davidbarratt commented 3 years ago

Ah, ok cool. Thanks!