GraphStore`

JSONLD (.jsonld)

Background

Import & Export

  • Import["file.jsonld"] imports a JSON-LD file, returning an RDFStore.
  • Import["file.jsonld",elements] imports the specified elements.
  • Export["file.jsonld",expr] exports an RDFStore to a JSON-LD file.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Data representation elements:
  • "Data"an RDFStore
    "RawData"nested associations and lists
  • The "RawData" element is equivalent to the "RawJSON" format. The import result can be "compacted", "expanded", or "flattened" by specifying the "Profile" and "Context" import options.

Options

  • Import options:
  • "Base"Automaticbase IRI used to resolve relative IRIs
    "DocumentLoader"Automaticfunction used to import remote contexts
    "ExpandContext"Nonecontext used to initialize the active context during expansion
    "ProduceGeneralizedRDF"Falsewhether to import a file that contains a blank node in a property position
  • The value of "Base" is only used if the file does not specify a base IRI.
  • "Base" can take the following values:
  • Automaticthe file name of the imported file
    Noneno base IRI
    "iri" or URL["iri"]an IRI
  • An "ExpandContext" can be given to import a JSON file as an RDFStore.
  • Additional Import options for the "RawData" element:
  • "CompactArrays"Truewhether arrays of one element should be replaced with that element
    "Context"Nonecontext used for compaction
    "Profile"Nonehow to represent data as JSONLD
  • Specifying the "CompactArrays", "Context" and "Profile" options during "RawData" import has the same effect as specifying those options during Export.
  • Export options:
  • "CompactArrays"Truewhether arrays of one element should be replaced with that element
    "Context"Nonecontext used for compaction
    "ExpandContext"Nonecontext used to initialize the active context during expansion
    "Profile""Compacted"how to represent data as JSONLD
    "UseNativeTypes"Falsewhether number and Boolean literals should be expressed as JSON numbers and Booleans
    "UseRDFType"Falsewhether rdf:type predicates should be exported as rdf:type or @type
  • A "Context" is an association that specifies how short terms relate to IRIs, which datatypes values have and which classes IRIs belong to.
  • A "Profile" specifies how data is represented as JSONLD. Possible value include:
  • "Compacted"shorten IRIs to terms and compact IRIs, and values to numbers and string
    "Expanded"expand all terms and schort forms
    "Flattened"collect all properties of a node into a single JSON object and generate a label for each blank node

Examples

open allclose all

Basic Examples  (1)

Import a document describing Albert Einstein:

Find the date of birth:

Export the same graph:

Specify a "context" to compact keys and values:

Applications  (1)

Import a Turtle document about the masses of various objects:

Specify a context:

Export the RDF graph as JSON-LD: