Skip to content

Add support for JSON-LD #1

@lanthaler

Description

@lanthaler

Have you considered supporting JSON-LD as well? I think that would be quite straightforward given that everything is in RDF. Probably the simplest thing would be to use an existing JSON-LD processor and convert the N-Triples (N-Quads) automatically to JSON-LD. With my processor (https://github.com/lanthaler/JsonLD) the code would look more or less like this:

use ML\JsonLD\JsonLD;

$document = JsonLD::fromQuads($quads);

//  Optional: use short terms instead of full IRIs for properties
$document = JSONLD::compact($document, 'context.jsonld');

print JsonLD::toString($document, true);

This would then output something along the lines of:

{
  "@context": {
    // the context used above
  },
  "@id": "https://my-profile.eu/people/deiu/card#me>",
  "@type": "Person",
  "name": "Andrei Vlad Sambra",
  "givenName": "Andrei Vlad"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions