当前位置:网站首页>Hello JSON Schema
Hello JSON Schema
2022-07-17 14:26:00 【王老急888】
定义一个JSON接口,如何准确的描述它?
JSON schema可能是个好的方式。
https://json-schema.org/understanding-json-schema/reference/array.html
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
}
}
在线验证
https://www.jsonschemavalidator.net/
Ajv
https://ajv.js.org/guide/getting-started.html
yarn add ajv
Example
import Ajv from 'ajv';
const schema = {
type: 'array', minItems: 4, maxItems: 4, items: {
type: 'integer', minimum: 0, maximum: 255 } };
const ajv = new Ajv();
const validate = ajv.compile(schema);
console.log(validate([1, 2, 3, 4]));
边栏推荐
- Configuration of vscode+unity3d
- Tire Defect Detection Using Fully Convolutional Network-论文阅读笔记
- JVM钩子hooks函数
- Mpu9250 ky9250 attitude, angle module and mpu9250 MPL DMA comparison
- nodeJS中promise对象对结果简便输出办法(建议使用异步终极方案 async+await)
- web安全入门-部署Snort开源IDS/IPS系统
- Introduction to the universal theme system of SAP appgyver
- Documents required for military product development process - advanced version
- pjudge#21652-[PR #4]到底有没有九【数位dp】
- Introduction to sap appgyver
猜你喜欢

LeetCode 558. 四叉树交集

数据库锁的介绍与InnoDB共享,排他锁

A fastandrobust convolutionalneuralnetwork-based defect detection model inproductqualitycontrol-阅读笔记
![Some methods of early MCU encryption [get data in the comment area]](/img/14/8e1dcb799d8a3c0aefcac09be9dc51.png)
Some methods of early MCU encryption [get data in the comment area]

Mysql索引的类型(单列索引、组合索引 btree索引 聚簇索引等)

LeetCode 558. Intersection of quadtree

Delegate parents and other loaders

Today's sleep quality record 79 points

Four methods of traversing key value in map

mpu9250 ky9250姿态、角度模块和mpu9250 mpl dma对比
随机推荐
《MySQL DBA封神打怪之路》专栏学习大纲
SSM uses POI to export data to excel
LeetCode 558. Intersection of quadtree
如何在 RHEL 9 中更改和重置忘记的root密码
Satellite network capacity improvement method based on network coding
input number 純數字輸入 限制長度 限制 最大值
Unity dropdown (editable, inputable) drop-down selection box with Text Association
Unity3d 模型中心点的转换(源代码)
Whether pjudge 21652-[pr 4] has nine [digit DP]
数据库锁的介绍与InnoDB共享,排他锁
A curated list of awesome Qt and QML
Qt--优秀开源项目
Loj#2324-「清华集训 2017」小 Y 和二叉树
Svn learning
Keras深度学习实战(14)——从零开始实现R-CNN目标检测
Sword finger offer II 041 Average value of sliding window
Introduction to common distributed locks
Pytorch. NN implementation of multi-layer perceptron
synchronized锁升级
Pytoch and weight decay (L2 norm)