1
在spec http://json-schema.org/latest/json-schema-core.html,它只以下类型列表: 空, 布尔,字符串 , 数, 对象, 阵列。JSON模式类型整数
我知道数字包括整数,但我可以明确定义“类型”:“整数”。我的意思是这会违反规范吗?
在spec http://json-schema.org/latest/json-schema-core.html,它只以下类型列表: 空, 布尔,字符串 , 数, 对象, 阵列。JSON模式类型整数
我知道数字包括整数,但我可以明确定义“类型”:“整数”。我的意思是这会违反规范吗?
是的,您可以在架构中使用{"type": "integer"}
。
参见:
https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.5
https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2
还有的JSON模式GitHub的页面上询问的正是这种问题... https://github.com/json-schema-org/json-架构规格/问题/ 272 –