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!

1 Answer 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).

Sign up to request clarification or add additional context in comments.

2 Comments

Hello Markus, thank you very much for your reply and this works. However, I wonder what I can do if I want to have more than one type. Would that look like this? { "@context": { "myvocab": "http://localhost:8080/schema.json#", "Information": { "@id": "myvocab:Information", "@type": "@id" }, "name": "http://schema.org/name", "active": "http://schema.org/Boolean", "OtherInformation": { "@id": "myvocab:Information", "@type": "@id" }, "otherName": "http://schema.org/name", "otherActive": "http://schema.org/Boolean" }
Especially, I wonder how the paramters "name" and "active" are considered part of "Information" and not, for example. "OtherInformation".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.