我有一个存储在我的nosql Mongodb数据库中的json数据(我无法更改)。 这就是数据的样子:
{"scans" : {
"Bkav" : {
"detected" : false,
"version" : "1.3.0.4924",
"result" : null,
"update" : "20140214"
},
"MicroWorld" : {
"detected" : false,
"version" : "12.0.250.0",
"result" : null,
"update" : "20140216"
},
"nProtect" : {
"detected" : false,
"version" : "2014-02-16.01",
"result" : null,
"update" : "20140216"
}
}
}
我要做的是创建一个基于spring boot的rest webservice来检索存储在mongo中的数据,所以我需要设置我的模型(基于json格式)这就是我的意思想出了:
public class Scans
{
@Id
private String id;
private Bkav Bkav;
private NProtect nProtect;
private MicroWorld-eScan MicroWorld-eScan;
//getters and setters
@Override
public String toString()
{
return "ClassPojo [Bkav = "+Bkav+", nProtect = "+nProtect+", MicroWorld-eScan = "+MicroWorld-eScan+"]";
}
}
对于每个扫描仪(Bkav,nProtect,MicroWorld-escan),我都有相同的型号:
public class "scanner" //that may be one of the above names;
{
private String update;
private String result;
private String detected;
private String version;
//getters and setters
@Override
public String toString()
{
return "ClassPojo [update = "+update+", result = "+result+", detected = "+detected+", version = "+version+"]";
}
}
因此我可以为所有扫描仪创建一个类,因为我的问题比我在问题中列出的更多
答案 0 :(得分:1)
首先, $('.voyageFileCall').on('click', function()
{
var voyage = $(this).attr('data-voyage');
$.post('fileDownload.php', {voyage:voyage}, function(data)
{
if(document.getElementById("myDownload")){
document.getElementById("myDownload").click();
}else{
console.log("file does not exist");
}
});
});
不是有效的类或变量名
根据我的经验,你需要拥有这个模型
MicroWorld-eScan
我建议使用其他名称与public class Scans {
@Id
private transient String id;
private TreeMap<String, Scanner> scans;
// for example
public Bkav getBkav() {
return map.get("Bkav");
}