From c2a87e7b1bbe313b47e640afe9bf9840b87c09ca Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Fri, 23 May 2025 09:44:03 +0800 Subject: [PATCH] jsonArray_fix Signed-off-by: lanhaoyu --- adapter/ohos/Compressor.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 90bda4f0..9076a984 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -4220,12 +4220,16 @@ public class Compressor { } private static void writeGeneralRecord(List> recordList, String outPath) { + JSONArray jsonArray = new JSONArray(); try (FileWriter fileWriter = new FileWriter(outPath + LINUX_FILE_SEPARATOR + GENERAL_RECORD)) { for (HashMap record : recordList) { - String jsonString = JSON.toJSONString(record); - fileWriter.write(jsonString); - fileWriter.write(","); + JSONObject jsonObject = new JSONObject(); + for (Map.Entry entry : record.entrySet()) { + jsonObject.put(entry.getKey(), entry.getValue()); + } + jsonArray.add(jsonObject); } + fileWriter.write(jsonArray.toString()); } catch (IOException e) { LOG.error(PackingToolErrMsg.IO_EXCEPTION.toString("Write general record exist IOException: " + e.getMessage())); -- Gitee