From 262639465991c397a81ad7cef4546ee1fb846c63 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 5 May 2023 20:22:51 +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=8D=E6=8E=A5=E5=8F=A3=E8=AF=B7=E6=B1=82=E4=BD=93?= =?UTF-8?q?=E4=BC=9A=E7=BC=A9=E5=87=8F=E6=95=B0=E5=AD=97=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=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=1025842 --user=王孝刚 【接口测试】接口请求体会缩减数字精度 https://www.tapd.cn/55049933/s/1369188 --- .../metersphere/api/exec/generator/JSONSchemaParser.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaParser.java b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaParser.java index 0031784389..bfdaf1b5d7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaParser.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; +import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -122,11 +123,11 @@ public class JSONSchemaParser { } if (FormatterUtil.isMockValue(object)) { if (FormatterUtil.isNumber(FormatterUtil.getStrValue(object))) { - Number value = FormatterUtil.getElementValue(object).getAsNumber(); - if (value.toString().indexOf(".") == -1) { - concept.put(propertyName, value.longValue()); + String value = FormatterUtil.getElementValue(object).getAsString(); + if (value.indexOf(".") == -1) { + concept.put(propertyName, Integer.valueOf(value)); } else { - concept.put(propertyName, value.floatValue()); + concept.put(propertyName, new BigDecimal(value)); } } else { JSONSchemaBuilder.processValue(concept, processMap, propertyName, FormatterUtil.getStrValue(object));