From 0fefb82a60482d975e6c3ed2b250b6a0038156b0 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 22 Jan 2026 21:15:09 +0800 Subject: [PATCH] =?UTF-8?q?fix[=E6=95=B0=E6=8D=AE=E9=9B=86]:=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dapi=E6=95=B0=E6=8D=AE=E6=BA=90=E4=B8=AD=EF=BC=8Cjson?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=AD=97=E6=AE=B5=E4=BF=9D=E5=AD=98=E4=B8=BA?= =?UTF-8?q?=E4=B8=8D=E6=A0=87=E5=87=86json=E6=A0=BC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E9=80=9A=E8=BF=87=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=AD=97=E6=AE=B5=E7=9A=84=E5=87=BD=E6=95=B0=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=20#17772?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/provider/ApiUtils.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java index 678527256c..acfa1e5c17 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java @@ -610,6 +610,13 @@ public class ApiUtils { } for (Map field : fields) { JSONArray array = new JSONArray(); + String value = Optional.ofNullable(data.get(field.get("originName"))).orElse("").toString(); + if (value.startsWith("{") && value.endsWith("}")) { + try { + value = objectMapper.writeValueAsString(data.get(field.get("originName"))); + } catch (Exception e) { + } + } if (field.get("value") != null) { try { TypeReference listTypeReference = new TypeReference() { @@ -618,9 +625,9 @@ public class ApiUtils { } catch (Exception e) { DEException.throwException(e); } - array.add(Optional.ofNullable(data.get(field.get("originName"))).orElse("").toString().replaceAll("\n", " ").replaceAll("\r", " ")); + array.add(value.replaceAll("\n", " ").replaceAll("\r", " ")); } else { - array.add(Optional.ofNullable(data.get(field.get("originName"))).orElse("").toString().replaceAll("\n", " ").replaceAll("\r", " ")); + array.add(value.replaceAll("\n", " ").replaceAll("\r", " ")); } field.put("value", array); } @@ -838,7 +845,14 @@ public class ApiUtils { String[] row = new String[apiDefinition.getFields().size()]; int i = 0; for (TableField field : apiDefinition.getFields()) { - row[i] = Optional.ofNullable(data.get(field.getOriginName())).orElse("").toString().replaceAll("\n", " ").replaceAll("\r", " "); + String value = Optional.ofNullable(data.get(field.getOriginName())).orElse("").toString(); + if (value.startsWith("{") && value.endsWith("}")) { + try { + value = objectMapper.writeValueAsString(data.get(field.getOriginName())); + } catch (Exception e) { + } + } + row[i] = value.replaceAll("\n", " ").replaceAll("\r", " "); i++; } dataList.add(row);