我想從json數據文件生成json模式,如下所示(這是使用在線工具生成的,http://jsonschema.net/) 是否可以使用JSON.NET或其他?編程從JSON數據生成JSON模式
的Json數據文件:
{
"graph": [
{
"id": 453,
"cid": 143,
"title": "graph1",
"description": "",
"thumbnailPath": "art.jpg",
"detailPath": "art.jpg",
"link": "www.test.html",
"author": "graph Team"
},
{
"id": 12,
"cid": 121,
"title": "graph2",
"description": "",
"thumbnailPath": "art2.jpg",
"detailPath": "art2.jpg",
"link": "www.test2.html",
"author": "graph Team"
}
]
}
輸出:因爲我想生成它在程序運行我的目標是不使用工具
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "/",
"type": "object",
"properties": {
"graph": {
"id": "graph",
"type": "array",
"items": {
"id": "1",
"type": "object",
"properties": {
"id": {
"id": "id",
"type": "integer"
},
"cid": {
"id": "cid",
"type": "integer"
},
"title": {
"id": "title",
"type": "string"
},
"description": {
"id": "description",
"type": "string"
},
"thumbnailPath": {
"id": "thumbnailPath",
"type": "string"
},
"detailPath": {
"id": "detailPath",
"type": "string"
},
"link": {
"id": "link",
"type": "string"
},
"author": {
"id": "author",
"type": "string"
}
}
}
}
}
}
。
HMM你是對的...它不是那麼容易......調查 –