JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q50963F
  • License MIT

Json-ld and schema.org utilities

Package Exports

  • sambal-jsonld

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sambal-jsonld) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Json-ld utilities

Intro

Json-ld utility functions to transform any json data to json-ld. Support schema.org vocabularies.

API

toSchemaOrgJsonLd(json: any, type: string, context?: any)

json - any json data

type - schema.org type name

context - json-ld context

response - a schema.org json-ld object, automatically removing any fields with incorrect type or not in the type schema

async hydrateJsonLd(json: object, fetcher: (url) => Promise<any>, context?: any)

json - any json data

fetcher - User defined fetcher function to load url

context - json-ld context

response - a json object with all nested @id references populated

toJsonLdGraph(jsonlds: object[], context: any)

jsonlds - Array of json-ld

context - json-ld context

response - A flatten json-ld graph object

graphToCondensedJsonLd(jsonldGraph: object, id?: string)

jsonldGraph - json-ld graph

id - select an @id node

response - A list of json-ld objects