JSON Schema

Json schema 格式

Json schema 本身遵循Json规范,本身就是一个Json字符串,先来看一个例子

{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme‘s catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" }, "name": { "description": "Name of the product", "type": "string" }, "price": { "type": "number", "minimum": 0, "exclusiveMinimum": true } }, "required": ["id", "name", "price"]}

 

 

我们来看一下json schema 最外层包含以下几个字段

$schema描述示例
$schema$schema 关键字状态,表示这个模式与 v4 规范草案书写一致。 
title标题,用来描述结构 
description描述 
type类型.
properties定义属性 
required必需属性 

相关文章