Skip to main content

JSON-LD

This service allows you to manage JSON-LD formatted data.

Features

  • Manipulate JSON-LD data (frame, compact, expand...)
  • Manipulate JSON-LD contexts (parse, validate...)
  • Automaticaly generate a local JSON-LD context

Dependencies

Sub-services

Install

$ yarn add @semapps/jsonld

Usage

const path = require('path');
const { JsonLdService } = require('@semapps/jsonld');

module.exports = {
mixins: [JsonLdService],
settings: {
baseUri: 'http://localhost:3000',
localContextPath: '/.well-known/context.jsonld',
cachedContextFiles: [
{
uri: 'https://www.w3.org/ns/activitystreams',
file: path.resolve(__dirname, './config/context-as.json')
}
]
}
};

Service settings

PropertyTypeDefaultDescription
baseUriStringrequiredBase URL of the server.
localContextPathString"/.well-known/context.jsonld"Path of the automatically generated local JSON-LD context file
cachedContextFiles[Object]Context files to put in cache on start (see example above)