Orderly,描述JSON的文本格式
程序员文章站
2022-06-03 22:06:04
...
Lloyd Hilaiel,Yahoo! BrowserPlus的佼佼者创建了一个简单的库 -Orderly。它是一个描述JSON的文本格式,可以被编译为JSONSchema,易于读写。
代码:
A little bit of orderly...
JAVASCRIPT:
-
object {
-
string name;
-
string description?;
-
string homepage /^http:/;
-
integer {1500,3000} invented;
-
}*;
...describes a little bit of JSON...
JAVASCRIPT:
-
-
{
-
"name": "orderly",
-
"description": "A schema language for JSON",
-
"homepage": "http://orderly-json.org",
-
"invented": 2009
-
}
-
compiles into JSONSchema
JAVASCRIPT:
-
-
{
-
"type": "object",
-
"properties": {
-
"name": {
-
"type": "string"
-
},
-
"description": {
-
"type": "string",
-
"optional": true
-
},
-
"homepage": {
-
"type": "string",
-
"pattern": "^http:"
-
},
-
"invented": {
-
"type": "integer",
-
"minimum": 1500,
-
"maximum": 3000
-
}
-
},
-
"additionalProperties": true
-
}
查看Orderly文档:http://orderly-json.org/docs
上一篇: 前端 UI 框架对比