---
title: "Discussion on \"JSON Schema is a constraint system\" | Hashnode"
description: "Discussion on \"JSON Schema is a constraint system\". Or: Why object-oriented programming is a mis-matched mental model for JSON Schema"
url: "https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JSON Schema is a constraint system](https://modern-json-schema.com/json-schema-is-a-constraint-system?utm_source=hashnode&utm_medium=feed)

Or: Why object-oriented programming is a mis-matched mental model for JSON Schema

Nov 11, 2022 · 6 min read · modern-json-schema.com  
Updated Jul 24, 2025  
Read the article

-   [#json-schema](https://hashnode.com/tag/json-schema)
-   [#json](https://hashnode.com/tag/json)
-   [#java](https://hashnode.com/tag/java)
-   [#object-oriented-programming](https://hashnode.com/tag/object-oriented-programming)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Henry Andrews](https://hashnode.com/@handrews)

@handrews

  
[View profile](https://hashnode.com/@handrews)

JSON Schema specification co-author and API design enthusiast

I am a software engineer, REST API enthusiast, co-author of the JSON Schema, and occasional interactive theatre performer.

## Responses 3

Markdown supported · ⌘↵ to post

[Adam Leventhal](https://hashnode.com/@ahl)

[Oct 28, 2024](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/67200dfc67c5d34a50a6c76e)

This is a very eloquent articulation of an aspect of JSON Schema I've struggled to describe, making do with "in code we often describe what a thing is; JSON Schema describes what a thing isn't".

May I ask though: why? JSON Schema is--I presume--intended to serve programmatic uses. Why choose a constraint model that's at odds with a structural (or "object oriented") approach?

[Charlie Jonas](https://hashnode.com/@cjonas)

[Jun 14, 2023](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/648a347a1c2b5dbd4dc8e5d4)

While I understand the point this is making, it seems that many of the popular uses of JSONSchema are for "Definitions" (API Contracts). These typically are then used directly for "Code Generation".

Would you say that this is outside the scope of what JSONSchema was designed for?

[Henry Andrews](https://hashnode.com/@handrews)

[Mar 12, 2024](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/648a347a1c2b5dbd4dc8e5d4#reply-65f0839ec5f013b3d4818c63)

Yes, and since I'm also very involved in the OpenAPI Specification, I'm very familiar with this mismatch and the problems it causes. We did try to address that in an [appendix to the modern JSON Schema drafts](https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html#name-references-and-generative-u) , to show how to bridge that gap, but it hasn't really caught on so far. (apologies for the very long delay in replying, see my "Coming Out of Hibernation" post for an explanation)

[Rob Atkinson](https://hashnode.com/@ratkinson)

[Feb 17, 2023](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/63ef62733c9c765be7a4775d)

Is is worth tying these ideas into the concepts of open-world and closed-world views, and the consequent fairly natural match with RDF, and JSON-LD ?

[Henry Andrews](https://hashnode.com/@handrews)

[Mar 12, 2024](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/63ef62733c9c765be7a4775d#reply-65f08314c843953ec5b68bf5)

My understanding is that an open world allows for indeterminate truth values. Unless there's an error in the schema, it's always possible to determine whether a given instance is valid with respect to a given schema. It's just that the starting point (the empty schema) allows everything. So that would seem to me to be a closed world approach.

[David Kemp](https://hashnode.com/@davi9)

[May 22, 2024](https://hashnode.com/posts/json-schema-is-a-constraint-system/636ec3c29fcbe783317b2b8d/comment/63ef62733c9c765be7a4775d#reply-664e380e59083c7f0682ca34)

Does indeterminacy in an open world express a limitation of modeling a world, or indeterminacy in the model itself? (The map is not the territory, but given a map can truth be indeterminate?)

All sorts of vagueness exists in the real world, "Fred is bald" includes at least two: "which Fred?" and "what is bald?" But does an open world model require that subjects have a unique instance id and that the "bald" attribute is a binary type (or an integer threshold for number of hairs on the head)?

I'd assume that an open world model does not allow vagueness-based indeterminate truth (it follows the law of the excluded middle). Are there different scenarios where indeterminate truth is permitted in the model?

(Attributes can be optional, and if a subject does not have a "bald" attribute then the question cannot be answered for that subject. But that applies to both closed and open worlds.)
