Orderly,描述JSON的文本格式
程序员文章站
2022-03-03 15:04:12
...
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