解决gson异常转义

This commit is contained in:
liangdaliang
2025-03-13 14:10:31 +08:00
parent 1dc1961c65
commit 24f6f4bcf1
2 changed files with 7 additions and 3 deletions

View File

@@ -113,7 +113,7 @@ public class JMeterUtil {
// 解析 JSON 数组
List<Map<String, String>> headerList = null;
try {
requestHeader = requestHeader.replaceAll(",\\s*\\[\\{\"key\":\"\",\"value\":\"\"\\}]", "");
// requestHeader = requestHeader.replaceAll(",\\s*\\[\\{\"key\":\"\",\"value\":\"\"\\}]", "");
headerList = gson.fromJson(requestHeader, type);
// 将 List<Map<String, String>> 转换为 Map<String, String>
for (Map<String, String> entry : headerList) {
@@ -281,8 +281,8 @@ public class JMeterUtil {
// 将JSON字符串转换为List<Map<String, String>>
List<Map<String, String>> keyValuePairs = null;
try {
jsonString = jsonString.replaceAll(", \\[\\{\\}]", "");
jsonString = jsonString.replaceAll(",\\[\\{\\}]", "");
// jsonString = jsonString.replaceAll(", \\[\\{\\}]", "");
// jsonString = jsonString.replaceAll(",\\[\\{\\}]", "");
keyValuePairs = gson.fromJson(jsonString, listType);
} catch (Exception e) {
logger.error("gson.fromJson发生异常jsonString" + jsonString, e);

View File

@@ -64,6 +64,10 @@ export default {
item.childrenList = null;
let cindex = 1;
childrenList.forEach((children) => {
children.assertion.pop();
children.assignment.pop();
children.requestHeader.pop();
children.requestParams.pop();
p.push({
...children,
caseId: this.$route.query.id,