我的问题是如何知道使用哪个JSON模式来针对JSON进行验证?我在它的id字段中指定了模式的URL。这够了吗?我应该把这个ID放在JSON中吗?我不知道如何将JSON连接到特定的JSON模式。如何指定JSON实例是由特定的JSON模式定义的
这里是我的架构
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "url/schema.json",
"title": "title",
"definitions": {
"emailObject": {
"type": "object",
"properties":{
"name": {
"description": "The name of the customer",
"type": "string",
"maxLength": 200
},
"email": {
"description": "The email of the customer",
"type": "string",
"format": "email",
"maxLength": 100
}
}
}
}
你的第一个报价,从规范的一个,就是做正确的方式。 'describeby'的链接数据定义与JSON Schema规范不矛盾。这是一个有目的广泛的定义,因此它可以应用于描述数据的任何媒体类型。这包括JSON Schema,XML Schema或其他任何东西。 – Jason
谢谢@Jason我要更新我的答案 –
谢谢澄清,但我的问题是,我有一个服务器上的2个Json模式,我有一个Json对象,我需要用一个模式来验证它。但我不知道是否应该将ID放在Json对象中以链接它们,或者如何仅获取该对象的模式。 – Maria