我有一個POJO類生成Java類JSON模式
public class Stock{
int id;
String name;
Date date;
}
是否有任何註釋或開發框架/ API,可以POJO轉換成JSON架構如下圖所示
{"id":
{
"type" : "int"
},
"name":{
"type" : "string"
}
"date":{
"type" : "Date"
}
}
而且我可以通過在POJO上指定一些註釋或配置來擴展模式以添加諸如「必需」,「是」,每個字段的描述等的信息,並且可以像下面那樣生成JSON模式。
{"id":
{
"type" : "int",
"Required" : "Yes",
"format" : "id must not be greater than 99999",
"description" : "id of the stock"
},
"name":{
"type" : "string",
"Required" : "Yes",
"format" : "name must not be empty and must be 15-30 characters length",
"description" : "name of the stock"
}
"date":{
"type" : "Date",
"Required" : "Yes",
"format" : "must be in EST format",
"description" : "filing date of the stock"
}
}
這是你在找什麼? http://stackoverflow.com/questions/9593409/convert-pojo-to-json – Elric 2014-10-05 05:01:30
不,將pojo轉換成json對象。我正在尋找生成JSON模式作爲元[關於輸入表單字段映射到pojo字段的信息,如數據類型,是否需要,等等,]給最終用戶)。 – user3587174 2014-10-05 14:23:15
這是一個在線網站,將從json生成json模式:http://www.jsonschema.net/ – DwB 2014-10-06 19:07:57