rdflib-jsonld (Deprecated)

0.6.2 · abandoned · verified Thu Apr 16

rdflib-jsonld was a plugin for RDFLib that provided JSON-LD 1.0 parsing and serialization capabilities. As of RDFLib 6.0.1 (released September 2021), JSON-LD handling has been integrated directly into the core RDFLib library. The rdflib-jsonld library itself is now 'tombstoned', with version 0.6.2 being the final release that removes all core functionality, leaving only a deprecation warning. It is considered abandoned.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse and serialize JSON-LD data using the core `rdflib` library (version 6.0.1 or newer). The `rdflib-jsonld` package is no longer required for this functionality.

from rdflib import Graph

json_ld_data = '''
{
  "@context": "http://schema.org/",
  "@type": "Person",
  "name": "Jane Doe",
  "jobTitle": "Professor",
  "telephone": "(425) 123-4567",
  "url": "http://www.janedoe.com"
}
'''

# Create a graph and parse JSON-LD data
g = Graph().parse(data=json_ld_data, format='json-ld')

print("Graph contains %d triples." % len(g))

# Serialize the graph back to JSON-LD
serialized_json_ld = g.serialize(format='json-ld', indent=4)
print("\nSerialized JSON-LD:")
print(serialized_json_ld)

# Example of querying a triple
from rdflib import URIRef, Literal, Namespace
from rdflib.namespace import RDF

schema = Namespace("http://schema.org/")

for s, p, o in g.triples((None, schema.name, None)):
    print(f"Found name: {o}")

view raw JSON →