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 Schema

PreviousFirst SchemaNextCompilation into JSON-LD Context

Last updated 1 year ago

Was this helpful?

Our fictitious application uses to communicate messages between the blogging server and the client that displays blog posts. Each exchanged JSON document contains information about users or blog posts. Information must be organized in a certain way agreed upon by the client and server. This can be formalized using a specifying the structure of the exchanged JSON documents. For instance, here is a possible JSON Schema describing the structure of a JSON document containing a blog post (it is also a JSON document):

{
	"type": "object",
	"properties": {
		"title": {
			"type": "string"
		},
		"content": {
			"type": "string"
		}
	},
	"required": [
		"title",
		"content"
	]
}

You may notice that this definition is very close to the TreeLDR definition of BlogPost. For this reason, TreeLDR can be used to automatically generate this schema from our schema.tldr file using the tldrc compiler.

On linux or macOS, type the following command in your terminal:

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

This commands imports the schema.tldr with the -i option, calls the json-schema subcommand to generate a JSON Schema and specifies what schema we want to generate. Here we want to generate a JSON Schema for BlogPost, which is identified by the https://example.com/BlogPost IRI (once resolved against the base IRI). The output should match the JSON Schema above.

🔗
JSON
JSON Schema