0

I try to create my own Context for a project. However, after using Compact some Properties will be missing. Please see this example:

{
  "@context":
  {
    "myvocab": "http://localhost:8080/schema.json#",
    "Information":
    {
      "@id": "myvocab:Information",
      "@type": "@id",
      "name": "http://schema.org/name",
      "active": "http://schema.org/Boolean"
    }
  },

  "Information": [
   {
     "@type": "myvocab:Information",
     "name": "myCustomName",
     "active": "true"    
   }
  ]
}

This example can also be found on the JSON-LD Playground. After Compacting, I cannot see the properties "name" and "active" anymore as they will be removed. This is also the case in the playground. However, I do not get an error in the @context part, so I assume it is correct.

Please help me to understand why that properies go missing and what I could do to see them correctly after parsing.

Thanks in advance!

4

1 回答 1

1

The nesting of your context is wrong. You mistakenly made name and active attributes of the Information mapping instead of making them term mappings on their own. Here's the fixed example:

{
  "@context":
  {
    "myvocab": "http://localhost:8080/schema.json#",
    "Information":
    {
      "@id": "myvocab:Information",
      "@type": "@id"
    },
    "name": "http://schema.org/name",
    "active": "http://schema.org/Boolean"
  },
  "Information": [
   {
     "@type": "myvocab:Information",
     "name": "myCustomName",
     "active": "true"    
   }
  ]
}

You might also want to check the mapping of active. You map it to a type instead of mapping it to a property (properties are lowercased in Schema.org, classes/types capitalized).

于 2015-03-16T21:21:42.170 回答