SpruceKit
SpruceID
  • 🌲SpruceKit Introduction
    • Decentralized Identity Overview
    • Glossary
  • ⚡Quickstart
  • SpruceKit Mobile
    • SpruceKit Showcase App
      • Installation
      • Getting Started
      • Issue a Showcase Credential
      • Present a Showcase Credential
    • SpruceKit Mobile SDK
      • Introduction
      • Core Components
        • StorageManager
        • KeyManager
        • CredentialPack
        • Card
        • IsoMdlPresentation
        • mDocReader/IsomDLReader
        • Document Scanner
      • SpruceKit iOS SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
      • SpruceKit Android SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present an mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
  • Verifiable Digital Credentials
    • ⚙️DIDKit
      • Installation
      • Core Concepts
      • DID Methods
      • Runtime Configuration
      • Specifications and Dependencies
      • Quickstart
      • DIDKit Packages
        • Command Line Interface
        • HTTP Server
        • Rust Crate
        • C Interface
        • Java and Android
        • Python
        • Javascript
      • DIDKit Examples
        • Core Functions (CLI)
        • Core Functions (HTTP)
        • did-web in minutes
        • Batch Generation & Verification
    • 🪪ISO mDL
      • Quickstart
      • Core Concepts
      • User Guide
  • Schema Definition Language
    • 🔗TreeLDR
      • TreeLDR Quickstart
        • First Schema
        • Compilation into JSON Schema
        • Compilation into JSON-LD Context
        • Writing a Layout
        • Simple Rust Integration
      • Types
        • Literal Types
      • Layouts
        • Primitive Layouts
        • Literal Layouts
        • Enumeration
        • Array Layout
        • References
      • Compiling
        • Schema Definition Formats
          • JSON Schema
          • JSON-LD Context
          • Resource Description Framework (RDF)
        • Programming Languages
          • Compiling to Rust
      • RDF Vocabulary
      • 💡TreeLDR Basics
        • Types and Layouts
        • Properties
        • Syntax
  • Witness for Credential Claims
    • 🔭Rebase
      • Core Library
      • Rust Client/Witness SDK
      • WASM Client SDK
      • Simple "Basic Post" Schema
      • DNS Witness Flow Schema
  • References
    • Contributing
    • Code of Conduct
Powered by GitBook
On this page

Was this helpful?

  1. Schema Definition Language
  2. TreeLDR
  3. TreeLDR Quickstart

Compilation into JSON-LD Context

PreviousCompilation into JSON SchemaNextWriting a Layout

Last updated 1 year ago

Was this helpful?

Our fictitious application uses to communicate messages between the different blogging servers constituting of the federation. JSON-LD is a JSON-based data exchange format. Whereas JSON Schema imposes constraints on the structure of the JSON document, JSON-LD does not impose any structural constraint. In return, JSON-LD requires the document to contain a JSON-LD context specifying the semantics of each part of the document. This means that two radically different JSON-LD documents can represent the exact same data thanks to their context definition.

Assume that we want to represent a BlogPost instance using the following JSON-LD document:

{
	"@context": ...,
	"title": "The Blog Post Title",
	"content": "The blog post content."
}

The @context key has a special meaning in JSON-LD and should contain the JSON-LD context necessary to interpret the document. In particular, it should specify how to interpret the title and content keys. In our case, those refer to the https://example.com/BlogPost/title and https://example.com/BlogPost/content properties respectively. We can hence define the JSON-LD context as so:

{
	"title": "https://example.com/BlogPost/title",
	"content": "https://example.com/BlogPost/content"
}

Once again instead of defining the JSON-LD context by hand, TreeLDR can generate it automatically using the tldrc compiler and the following command:

tldrc -i schema.tldr json-ld-context https://example.com/BlogPost

It is very similar to the command used to generate a JSON Schema. It imports the schema.tldr with the -i option, calls the json-ld-context subcommand to generate a JSON-LD context and specifies what context we want to generate. Here we want to generate a JSON-LD context for BlogPost, which is identified by the https://example.com/BlogPost IRI.

The output should match the JSON-LD context above.

🔗
JSON-LD