fix(接口测试): 修复请求体字符串空格丢失问题

This commit is contained in:
RubyLiu 2023-06-26 15:07:03 +08:00 committed by f2c-ci-robot[bot]
parent cc2dace12e
commit 95c1a1af3f
2 changed files with 10 additions and 2 deletions

View File

@ -14,6 +14,9 @@ export const jsonParse = (jsonStr) => {
return parseBoolean();
} else if (char === 'n') {
return parseNull();
} else if (char === ' ' || char === '\n') {
index++;
return parseValue();
} else {
return parseNumber();
}
@ -29,6 +32,9 @@ export const jsonParse = (jsonStr) => {
if (jsonStr[index] === ',') {
index++;
}
while (jsonStr[index] === ' ' || jsonStr[index] === '\n') {
index++;
}
}
index++;
return obj;
@ -47,6 +53,9 @@ export const jsonParse = (jsonStr) => {
}
function parseString() {
let str = '';
while(jsonStr[index] === ' ' || jsonStr[index] === '\n'){
index++;
}
index++;
while (jsonStr[index] !== '"') {
str += jsonStr[index];

View File

@ -257,8 +257,7 @@ export default {
if (this.body.format === 'JSON-SCHEMA') {
if (this.body.raw) {
try {
const tmpStr = trimAll(this.body.raw)
const tmpObj = jsonParse(tmpStr)
const tmpObj = jsonParse(this.body.raw)
this.body.jsonSchema = MsConvert.format(tmpObj);
} catch (e) {
this.body.format = 'JSON';