How to use @rdfjs/serializer-jsonld - 1 common examples

To help you get started, we’ve selected a few @rdfjs/serializer-jsonld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikibus / Alcaeus / src / MediaTypeProcessors / RdfProcessor.ts View on Github external
import * as inferences from './inferences'

interface ConverterMap {
    [type: string]: (value: string, type: string) => unknown;
}

export interface IMediaTypeProcessor {
    canProcess(mediaType: string);
    process(
        alcaeus: IHydraClient,
        uri: string,
        response: IResponseWrapper,
        apiDocumentation?: ApiDocumentation): Promise;
}

const jsonldSerializer = new JsonLdSerializer()

const parserFactory = new ParserFactory()

function isRdfList (resource) {
    let isObject = typeof resource === 'object'
    if (isObject) {
        const isEmpty = resource[Constants.JsonLd.Id] === rdf.nil
        const isListNode = rdf.first in resource && rdf.rest in resource
        return isEmpty || isListNode
    }

    return false
}

async function parseAndNormalizeGraph (responseText: string, uri: string, mediaType: string): Promise {
    const parsers = parserFactory.create(uri)

@rdfjs/serializer-jsonld

JSON-LD serializer that implements the RDF/JS Sink interface

MIT
Latest version published 11 months ago

Package Health Score

65 / 100
Full package analysis

Popular @rdfjs/serializer-jsonld functions