我是json-schema的新手,我想用json-schema验证json数据,
这是我的json数据
{
users: [
{
"id": 1,
"username": "davidwalsh",
"phoneNumber": 987654321
},
{
"id": 2,
"username": "russianprince",
"phoneNumber": 9876541234
}
]
}
这是我的json-Schema
{
"type" : "object",
"properties" : {
"users" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"id": { "type": "number" },
"username": { "type" : "string" },
"phoneNumber": {"type": "number" }
}
}
}
}
}
现在我不知道如何在程序中执行这些文件。 如果有任何人有任何例子,请提供一些链接。 谢谢。
答案 0 :(得分:1)
JSON Schema本身不是“可执行的”。它们是描述其他文档的文档。
要执行类似验证的操作,您需要一个同时将数据和架构作为输入的验证器。 JSON Schema主站点有list of software,可能会有所帮助。 :)