【发布时间】:2020-07-13 02:05:15
【问题描述】:
所以我必须将 List<ClassObject> 行转换为 JsonObjects 以发送到休息调用。 List 有大约 10,000 行数据。那么任何人都可以建议我一种简单的方法来转换 JsonObject 中的列表数据吗?现在我正在使用 for 循环迭代列表数据,然后放入 JsonObject ,但这需要很多时间。
for (DeviceMasterForm dirtyForm : dirtyMasterFormsOnly) {
tableObject = new JSONObject();
tableObject.put("id", dirtyForm.getMasterForm().getId());
tableObject.put("strFormTitle", dirtyForm.getMasterForm().getStrFormTitle());
tableObject.put("iTemplateVersionNumber", dirtyForm.getMasterForm().getiTemplateVersionNumber());
tableObject.put("iViewSequence", dirtyForm.getMasterForm().getiViewSequence());
tableObject.put("hasConditions", dirtyForm.getMasterForm().getHasConditions());
tableObject.put("flgDeleted", dirtyForm.getMasterForm().getFlgDeleted());
tableObject.put("dtCreated", dirtyForm.getMasterForm().getDtCreated());
tableObject.put("dtUpdated", dirtyForm.getMasterForm().getDtUpdated());
tableJsonArray.put(tableObject);
}
Exected result = [{"key":"value","key":"value"},{"key":"value","key":"value"}]
【问题讨论】:
标签: java json spring-boot