sucheng 5 месяцев назад
Родитель
Сommit
93bbf53873

+ 34 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/util/StringToJsonUtil.java

@@ -0,0 +1,34 @@
+package com.rongwei.rwapsserver.aps.util;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+/**
+ * @author :sc
+ * @since :2025/2/26
+ */
+public class StringToJsonUtil {
+    public static ProductionScheduleRetVo readFromJson(String filePath) throws IOException {
+
+        List<String> strings = Files.readAllLines(Paths.get(filePath));
+        StringBuilder jsonStr = new StringBuilder();
+        for (String string : strings) {
+            jsonStr.append(string);
+        }
+        JSONObject parse = JSONUtil.parseObj(jsonStr.toString());
+        ProductionScheduleRetVo res = BeanUtil.toBean(parse, ProductionScheduleRetVo.class);
+        return res;
+    }
+
+    public static void main(String[] args) throws IOException {
+        String filePath = "C:\\Users\\shangmi\\Downloads\\retjson.txt";
+        readFromJson(filePath);
+    }
+}