This page shows examples of using JSON schema $ref markup to reference definitions and other structures within your JSON schema definition to generate more complex and nested schema documents.

Example #1: Nested Tree (using Array)

This example demonstrates the use of JSON Schema referencing to include or pull in schema definitions from other parts of the document. Alpaca supports referencing within the same document using simple ids.

In this example, we allow the end user to create a tree structure of repeated leaf elements that can be nested as many levels deep as they wish.

Example #2: Deeply Nested Tree (loaded from data)

This example shows a deeply nested tree loaded with data. Note that unlike the previous example, this example uses a non-'create' view which allows data to bind.

Example #3: Internal Definitions

Here is an example of an object that derives one of its sub-object properties from a referenced definition. The definition is stored in a special definitions sub-object of the schema. This definitions sub-object anticipates support for JSON Schema v4.

© 2016 Gitana Software, Inc.

Alpaca is sponsored by