Skip to content

abbreviate keys in json serialization

instead of serializing with full IRIs as keys, abbreviate them and embed the appropriate context, e.,g.

{
  "@id": "http://hannah-arendt-edition.net/data/lmt3q003",
  "@type": "http://hannah-arendt-edition.net/elements/Item",
  "http://hannah-arendt-edition.net/elements/hasNote": {
    "@id": "_:b0",
    "@type": "http://hannah-arendt-edition.net/elements/Note",
    "http://hannah-arendt-edition.net/elements/hasBibRef": {
      "@id": "_:b1",
      "@type": "http://hannah-arendt-edition.net/elements/BibRef",
      "http://hannah-arendt-edition.net/elements/biblCorresp": "http://hannah-arendt-edition.net/bibliography#Lobkowicz",
      "http://hannah-arendt-edition.net/elements/biblScope": "123",
      "http://hannah-arendt-edition.net/elements/biblScopeN": "fe2"
    },
    "http://hannah-arendt-edition.net/elements/p": "<p xmlns=\"http://www.tei-c.org/ns/1.0\">TEST</p>",
    "http://hannah-arendt-edition.net/elements/rend": "Auto",
    "http://hannah-arendt-edition.net/elements/internalNote": null
  },
  "http://hannah-arendt-edition.net/elements/listCorresp": {
    "@id": "http://hannah-arendt-edition.net/volume/XIV"
  },
  "http://hannah-arendt-edition.net/elements/listId": "XIV-commentaryDataLifeOfTheMind"
}

should look like

{
  "@context": {
    "hadata": "http://hannah-arendt-edition.net/elements/"
  },
  "@id": "http://hannah-arendt-edition.net/data/lmt3q003",
  "@type": "hadata:Item",
  "hadata:hasNote": {
    "@id": "_:b0",
    "@type": "hadata:Note",
    "hadata:hasBibRef": {
      "@id": "_:b1",
      "@type": "hadata:BibRef",
      "hadata:biblCorresp": "http://hannah-arendt-edition.net/bibliography#Lobkowicz",
      "hadata:biblScope": "123",
      "hadata:biblScopeN": "fe2"
    },
    "hadata:p": "<p xmlns=\"http://www.tei-c.org/ns/1.0\">TEST</p>",
    "hadata:rend": "Auto",
    "hadata:internalNote": null
  },
  "hadata:listCorresp": {
    "@id": "http://hannah-arendt-edition.net/volume/XIV"
  },
  "hadata:listId": "XIV-commentaryDataLifeOfTheMind"
}

but, since roger does not know about any context, hand the context down as a prop

interface RogerProps {
  data?: string;
  schema: string;
  onSave?: (finalData: string | Record<string, any>) => Promise<void>;
  onChange?: (finalData: string | Record<string, any>) => void;
  endpoints?: SparqlConfig;
  outputAsJson?: boolean;
  hideActionButtons?: boolean;
  jsonldContext?: Context
}

interface Context {
  "@context": { [key: string]: any };
}

we will then need to add the context to the application schema aka shapesgraph

Edited by Stefan Hynek