版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37279783/article/details/84135549
JSONObject jsonObject = new JSONObject();
List<JSONObject> jsonList = new ArrayList<>();
for (THarvestDatasource tHarvestDatasource : list) {
JSONObject jsonObject2 = new JSONObject();
jsonObject2.element("dataPath",tHarvestDatasource.getDataPath());
jsonObject2.element("datasourceName",tHarvestDatasource.getDatasourceName());
jsonList.add(jsonObject2);
}
jsonObject.element("data",jsonList);
{
"data": [
{
"dataPath": "cd669a58f7bb454eb970a3403b01c39a",
"datasourceName": "采集RELA"
}, {
"dataPath": "f8d886a810f440e398eaa340eff717b0",
"datasourceName": "长生人寿数据标准数据源"
}, {
"dataPath": "be32616ebbbb43c5a6fae9aa1d927cb5",
"datasourceName": "数据标准采集数据源1008"
}
]