Understanding JSON Schema

What is JSON Schema? JSON Schema is a declarative language that allows you to annotate and validate JSON documents. (annotate: to add notes / validate: to verify) ⇒ As the name suggests, it’s a schema for JSON, used to describe and validate items. The sender of data can describe the data and define types, and the receiver can validate the data through the schema before using it. Simply put, it can be described as a specification created to reduce various difficulties when exchanging data in JSON. For example, you receive data in JSON from an API or message queue: { id: "34", … }. How should we interpret this? Is it always a string? Could it have been sent incorrectly? If I set up parsing to receive it as a String, but one day it comes as an Integer, how should I handle it? To solve these problems, you can clearly specify the data structure through a schema and ensure data quality. Because there’s a standard specification on ‘how to define the schema’, you can automate the reading and sending according to the standard. Let’s see what it looks like. ...

July 16, 2023 · 712 words · Mihyang Gu