diff --git a/backend/src/main/java/io/metersphere/commons/json/JSONToDocumentUtils.java b/backend/src/main/java/io/metersphere/commons/json/JSONToDocumentUtils.java index c5c7667ee2..f40a6ab0e6 100644 --- a/backend/src/main/java/io/metersphere/commons/json/JSONToDocumentUtils.java +++ b/backend/src/main/java/io/metersphere/commons/json/JSONToDocumentUtils.java @@ -76,6 +76,7 @@ public class JSONToDocumentUtils { JSONArray array = JSON.parseArray(json); jsonDataFormatting(array, children); } else { + roots.add(new DocumentElement().newRoot(BasicConstant.ARRAY, children)); JSONArray array = JSON.parseArray(json); jsonDataFormatting(array, roots); } @@ -85,6 +86,7 @@ public class JSONToDocumentUtils { JSONObject object = JSON.parseObject(json); jsonDataFormatting(object, children); } else { + roots.add(new DocumentElement().newRoot(BasicConstant.OBJECT, children)); JSONObject object = JSON.parseObject(json); jsonDataFormatting(object, roots); } diff --git a/frontend/src/business/components/api/definition/api-definition.js b/frontend/src/business/components/api/definition/api-definition.js index 8e095afb9d..14cb963c87 100644 --- a/frontend/src/business/components/api/definition/api-definition.js +++ b/frontend/src/business/components/api/definition/api-definition.js @@ -183,7 +183,11 @@ export function mergeRequestDocumentData(request) { if (index !== -1) { if (request.hashTree[index].document && request.hashTree[index].document.originalData && request.hashTree[index].document.tableData.size && request.hashTree[index].document.tableData.size !== 0) { mergeDocumentData(request.hashTree[index].document.originalData, request.hashTree[index].document.tableData); - request.hashTree[index].document.data.json = request.hashTree[index].document.originalData; + if (request.hashTree[index].document.type === 'json') { + request.hashTree[index].document.data.json = request.hashTree[index].document.originalData; + } else { + request.hashTree[index].document.data.xml = request.hashTree[index].document.originalData; + } } } } diff --git a/frontend/src/business/components/api/definition/components/assertion/document/DocumentBody.vue b/frontend/src/business/components/api/definition/components/assertion/document/DocumentBody.vue index f8fa773308..a7e15e5d03 100644 --- a/frontend/src/business/components/api/definition/components/assertion/document/DocumentBody.vue +++ b/frontend/src/business/components/api/definition/components/assertion/document/DocumentBody.vue @@ -196,7 +196,7 @@ export default { if (this.document.type === "JSON") { this.document.data.json = this.originalData; } else if (this.document.type === "XML") { - this.document.data.xml = this.tableData; + this.document.data.xml = this.originalData; } }, tableDataList(data) { @@ -311,7 +311,7 @@ export default { if (this.document.data.xmlFollowAPI) { this.getDocument(); } else { - this.tableData = this.document.data.xml; + this.tableDataList(this.document.data.xml); } } this.reload();