How to structure json-ld for export/import

28 Views Asked by At

I am working on FlashCards app and I want to use json-ld for importing/exporting data from the app. I created simple structure but I am not sure if what I have done is valid and the links between the data are properly set.

  1. I am not sure if the link between FlashCardSide:language and Dictionary:availableLanguage is created
  2. FlashCard is of type Thing, and I have FlashCard:contains which is supposed to be not valid property, still validation passes.
  3. How should I define the types and properties that are not from schema.org ex:Dictionary, ex:FlashCardSide,
  4. Should I put some json-ld definitions on the site. something like https://example.com/ontology.jsonld
  5. How should acceptedValue be defined

Here is sample of the json-ld:

{
  "@context": {
    "ex": "https://example.com/",
    "schema": "http://schema.org/",
    "id": "@id",
    "type": "@type",
    "Dictionary": "ex:Dictionary",
    "Language": "schema:Language",
    "FlashCard": "schema:Thing",
    "FlashCardSide": "ex:FlashCardSide",
    "availableLanguage": "schema:availableLanguage",
    "name": "schema:name",
    "value": "schema:value",
    "description": "schema:description",
    "isPartOf": "schema:isPartOf",
    "itemListElement": "schema:itemListElement"
  },
  "id": "ex:dictionary/0117649e-f5af-486e-9d4d-756c335f7e53",
  "type": "Dictionary",
  "availableLanguage": [
    {
      "id": "ex:language/norwegian",
      "type": "Language",
      "name": "norsk"
    },
    {
      "id": "ex:language/english",
      "type": "Language",
      "name": "english"
    }
  ],
  "itemListElement": [
    {
      "id": "ex:flashcard/0117649e-f5af-486e-9d4d-756c335f7e51",
      "type": "FlashCard",
      "contains": [
        {
          "type": "FlashCardSide",
          "value": "hund",
          "isPartOf": "ex:language/norwegian",
          "acceptedValue": ["random-123"],
          "description": "<p>additional details</p>"
        },
        {
          "type": "FlashCardSide",
          "value": "dog",
          "isPartOf": "ex:language/english",
          "acceptedValue": ["random-123"],
          "description": "<p>additional details</p>"
        }
      ]
    },
    {
      "id": "ex:flashcard/0117649e-f5af-486e-9d4d-756c335f7e52",
      "type": "FlashCard",
      "contains": [
        {
          "type": "FlashCardSide",
          "value": "eple",
          "isPartOf": "ex:language/norwegian",
          "acceptedValue": ["random-321"],
          "description": "<p>additional details</p>"
        },
        {
          "type": "FlashCardSide",
          "value": "apple",
          "isPartOf": "ex:language/english",
          "acceptedValue": ["random-321"],
          "description": "<p>additional details</p>"
        }
      ]
    }
  ]
}

I have tested it with both: https://validator.schema.org/ and https://json-ld.org/playground/ and it appears to be valid.

0

There are 0 best solutions below