JSON-LD
JSON-LD (JavaScript Object Notation for Linked Data) is a lightweight Linked Data format designed to integrate seamlessly with web technologies and APIs. It allows data to be serialized in a human-readable and machine-processable format, facilitating data linking and sharing across different systems.
Key Features of JSON-LD
JSON-LD is a lightweight syntax to structure data using the principles of Linked Data. It provides a way to make data more accessible and understandable both by humans and machines.
- Compatibility with JSON: JSON-LD is fully compatible with JSON, making it easy to integrate into existing systems.
- Context: The
@contextattribute allows you to map terms in your data to URLs, providing a way to specify the meaning of each term. - Compaction and Expansion: JSON-LD can be compacted or expanded to simplify data exchange.
- Internationalization: Support for multilingual data through
@languageand@direction. - Framing: JSON-LD framing allows you to query and transform JSON-LD data into a desired shape.
Compaction, Expansion, and Framing in JSON-LD
Compaction
Compaction is the process of transforming JSON-LD data into a more compact form, using the @context to replace URLs with short names.
Expansion
Expansion transforms JSON-LD data into a form where all the terms are expanded to their full URLs.
Framing
Framing allows you to specify a frame (template) to query and restructure JSON-LD data. This is useful for extracting specific data from a larger JSON-LD document.
Example
The following JSON-LD example represents the credential of a Natural Person:
{
"@context": ["https://www.w3.org/ns/credentials/v2", "https://oid.spherity.com/contexts/oid/v1.jsonld"],
"type": ["VerifiableCredential", "LegalEntityCertificate"],
"id": "urn:uuid:f086cced-1153-4540-993b-b4d52ca499c2",
"validFrom": "2019-12-03T12:19:52Z",
"validUntil": "2029-12-03T12:19:52Z",
"issuer": "did:key:z6MkiY62766b1LJkExWMsM3QG4WtX7QpY823dxoYzr9qZvJ3",
"credentialSubject": {
"id": "did:key:fictive-1",
"type": "NaturalPerson",
"givenName": "John",
"familyName": "DOE",
"gender": "Male",
"birthDate": "1970-01-01",
"domicile": {
"postalCode": "10119",
"addressCountry": "Germany",
"addressLocality": "Berlin"
}
}
}
Using JSON-LD in OID application
In OID application, we use JSON-LD to ensure data interoperability and connectivity with external datasets. Notably, JSON-LD is the format used in W3C Verifiable Credentials, which is why we have adopted it for our credential management.
The whole JSON-LD handling will be abstracted by the libraries used in the W3C-VC implementation. If we would have some custom JSON-LD operations, we would use the the jsonld.js library, which provides robust tools for parsing, manipulating, and serializing JSON-LD data.
But on the application level, we will mostly work with the jsonld-signatures and jsonld-document-loader to create and verify digital signatures on JSON-LD data.
For more detailed information, visit the JSON-LD website.