From a9262201bc1ed28d75f0a222610f61902d0c651c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 11 May 2021 14:04:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20jsonpath=E6=96=AD=E8=A8=80=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jmeter/assertions/JSONPathAssertion.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java b/backend/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java index f841c5d255..7578e338c1 100644 --- a/backend/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java +++ b/backend/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java @@ -5,16 +5,10 @@ package org.apache.jmeter.assertions; +import com.google.gson.Gson; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Predicate; - -import java.io.Serializable; -import java.text.DecimalFormat; -import java.util.Map; -import java.util.function.Supplier; - import net.minidev.json.JSONArray; -import net.minidev.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.testelement.AbstractTestElement; @@ -24,6 +18,10 @@ import org.apache.oro.text.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Serializable; +import java.text.DecimalFormat; +import java.util.Map; + public class JSONPathAssertion extends AbstractTestElement implements Serializable, Assertion, ThreadListener { private static final Logger log = LoggerFactory.getLogger(JSONPathAssertion.class); private static final long serialVersionUID = 2L; @@ -212,7 +210,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab if (subj == null) { str = "null"; } else if (subj instanceof Map) { - str = (new JSONObject((Map) subj)).toJSONString(); + str = new Gson().toJson(subj); } else if (!(subj instanceof Double) && !(subj instanceof Float)) { str = subj.toString(); } else {