【发布时间】:2017-04-08 16:26:40
【问题描述】:
我是 json 的新手。我在 Json 模式中学习了更多东西,但在针对 json-schema.json 文件测试我的 user.json 文件时我无能为力。请注意,我需要使用 javascript 变量进行测试,该变量应返回 true 或 false 以进一步处理。在此我粘贴了我的文件。
json-schema.json
{
"description": "Any validation failures are shown in the right-hand Messages pane.",
"type": "object",
"properties": {
"foo": {
"type": "number"
},
"bar": {
"type": "string",
"enum": [
"a",
"b",
"c"
]
}
}
}
user.json
{
"foo": 12345,
"bar": "a"
}
当我在http://jsonschemalint.com/#/version/draft-05/markup/json 中测试上述代码时,IT 说 user.json 的格式正确。但我需要在本地测试
提前致谢。
【问题讨论】:
-
在浏览器中还是在应用中?
-
在浏览器中@Legends
-
嗨,mahi。我很清楚如何测试字符串是否为 JSON。
标签: javascript json jsonschema