Skip to Content
Unifying Business, Data, and Code
book

Unifying Business, Data, and Code

by Ron Itelman, Juan Cruz Viotti
January 2024
Intermediate to advanced
356 pages
9h 53m
English
O'Reilly Media, Inc.
Book available
Content preview from Unifying Business, Data, and Code

Chapter 13. Extending JSON Schema

Once we accept our limits, we go beyond them.

Albert Einstein

JSON Schema is used in a wide range of disparate use cases, from UI generation to data serialization. Given its wide applicability, the JSON Schema organization cannot possibly foresee every required feature. While the vocabularies that the JSON Schema organization defines are enormously powerful, there are cases for which you need to look beyond what’s offered out of the box. You saw a glimpse of this in Chapter 12, when JSON Schema didn’t provide keywords for declaring some of the metadata we wanted for the context facet of our example data product.

In Chapter 5, you learned an important skill: how to methodically understand every JSON Schema and consult documentation for keywords and vocabularies you haven’t seen before. This chapter builds on that to show how to define custom keywords that can do almost anything you want.

There are two ways in which you can extend JSON Schema:

  1. Exploit how JSON Schema collects annotations for unknown keywords (what we refer to as the simple case).

  2. Properly define and publish a JSON Schema vocabulary (what we call the complex case).

Although the simple case is easy to get going, it imposes limitations on how much you can make your keywords do.

Simple Case: Unknown Keywords

When performing validation, JSON Schema implementations will silently ignore any keywords they do not recognize. This fact can be easily exploited to add arbitrary metadata ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Contracts

Data Contracts

Chad Sanderson, Mark Freeman, B. E. Schmidt
Data Governance: The Definitive Guide

Data Governance: The Definitive Guide

Evren Eryurek, Uri Gilad, Valliappa Lakshmanan, Anita Kibunguchy-Grant, Jessi Ashdown
Data Management at Scale

Data Management at Scale

Piethein Strengholt

Publisher Resources

ISBN: 9781098144999Errata Page