JSON Schema
JSON Schema is a JSON-based schema definition language. It defines the expected layout of a JSON document, but does not describe its semantics.
TreeLDR can generate a JSON Schema from a TreeLDR layout. It can also import a TreeLDR layout from a JSON Schema, although it will result in an orphan layout: a layout not associated to any type, and without any semantic information. For instance, the above JSON Schema is equivalent to the following TreeLDR layout:
Generating a JSON Schema
Generating a JSON-LD context is done by using the json-schema
subcommand of the command line utility after the list of inputs, and by specifying what layout should be turned into a JSON Schema.
For instance, consider the following layout for the schema:BlogPosting
type:
Use the following command to generate JSON Schema context:
Running that generates:
The resulting schema loses any Linked Data information.
Importing a JSON Schema
The TreeLDR compiler (tldrc
) can import a JSON Schema like any other input document using the -i
option. This will import the JSON Schema as an orphan TreeLDR layout. For instance, we can import and export back the previously generate JSON Schema above, and we will get back the same document:
Last updated