From 95ccae7283063afdd713d0e5ace0e40442e67c90 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 28 Dec 2022 11:54:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Djson=E6=A0=BC=E5=BC=8F=E7=9A=84=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=95=B0=E6=8D=AE=E5=86=92=E5=8F=B7=E8=A2=AB=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E6=88=90=E7=AD=89=E5=8F=B7=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021303 --user=王孝刚 【接口测试】github#20973,接口中JSON格式的数据请求中的:被系统替换成了=号 https://www.tapd.cn/55049933/s/1320278 --- .../main/java/io/metersphere/api/dto/scenario/Body.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index 5a4458d41c..f976244d43 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -102,18 +102,19 @@ public class Body { } else { try { if (StringUtils.isNotEmpty(this.getRaw())) { - if (StringUtils.startsWith(this.getRaw(), "[") && StringUtils.endsWith(this.raw, "]")) { + String value = StringUtils.chomp(this.getRaw().trim()); + if (StringUtils.startsWith(value, "[") && StringUtils.endsWith(value, "]")) { List list = JSON.parseArray(this.getRaw()); if (!this.getRaw().contains("$ref")) { jsonMockParse(list); } - this.raw = JSONUtil.parser(list.toString()); + this.raw = JSONUtil.parser(JSONUtil.toJSONString(list)); } else { Map map = JSON.parseObject(this.getRaw(), Map.class); if (!this.getRaw().contains("$ref")) { jsonMockParse(map); } - this.raw = JSONUtil.parser(map.toString()); + this.raw = JSONUtil.parser(JSONUtil.toJSONString(map)); } } } catch (Exception e) {