我对json对象具有以下架构:
{
"pRequest": {
"ClsBuildingExeReport":{
"BuildingExecRep_FormOperation_Main" : {
"NIdBuildingExecRep" : "777"
},
"BuildingExecRep_Detail_Main": [
{
"BuildingExecDate": "2001/09/03",
"BuildingExecTime": "11:13:17",
"CI_ExecFloor": 0,
"CI_ExecLevel": 9,
},
{
"BuildingExecDate": "2001/09/03",
"BuildingExecTime": "11:13:17",
"CI_ExecFloor": 0,
"CI_ExecLevel": 9,
}...],
"_NidProc": "00000000-0000-0000-0000-000000000000"
}
}
}
我这样BuildingExecRep_FormOperation_Main
:
buildingExecRepFormOperationMain.put("NIdBuildingExecRep", nIdBuildingExecRep);
clsBuildingExeReport.put("BuildingExecRep_FormOperation_Main",
buildingExecRepFormOperationMain);
clsBuildingExeReport2.put("ClsBuildingExeReport", clsBuildingExeReport);
这样,我将json对象添加到ClsBuildingExeReport
对象中。
现在我已经创建了BuildingExecRep_Detail_Main
,如何将这个ArrayList添加到ClsBuildingExeReport
对象中?
buildingExecRep_Detail_Main3.put("BuildingExecRep_Detail_Main", buildingExecRep_Detail_Main);
clsBuildingExeReport2.put("ClsBuildingExeReport", buildingExecRep_Detail_Main3);
当我执行此代码ClsBuildingExeReport
时,只有一个对象,而其他对象似乎被覆盖。
答案 0 :(得分:0)
我认为这会有所帮助。
更改此
clsBuildingExeReport2.put("ClsBuildingExeReport", buildingExecRep_Detail_Main3);
通过
clsBuildingExeReport2.accumulate("ClsBuildingExeReport", buildingExecRep_Detail_Main3);
当您使用.put时,只需检查具有给定关键字的对象(在您的情况下为ClsBuildingExeReport
)是否存在,是否存在,它将替换但.accumulate在其中添加新对象现有对象。