JSON Schema: A Media Type for Describing JSON Documents
JSON Schema 是用于定义 JSON Data 结构的 JSON 数据,可帮助校验 JSON Data 是否合规。
听起来有点绕,下面看个简单的例子帮助理解。
下面是常规的 JSON Data
{
"name": "张三",
"age": 20
}
下面是用 JSON Schema 对上面数据的定义
{
"title": "Person",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["name", "age"]
}
本文主要是用于mark的,有兴趣的朋友可以去官网进一步了解。
网友评论