fix(接口测试): 修复请求体字符串空格丢失问题
This commit is contained in:
parent
cc2dace12e
commit
95c1a1af3f
|
@ -14,6 +14,9 @@ export const jsonParse = (jsonStr) => {
|
||||||
return parseBoolean();
|
return parseBoolean();
|
||||||
} else if (char === 'n') {
|
} else if (char === 'n') {
|
||||||
return parseNull();
|
return parseNull();
|
||||||
|
} else if (char === ' ' || char === '\n') {
|
||||||
|
index++;
|
||||||
|
return parseValue();
|
||||||
} else {
|
} else {
|
||||||
return parseNumber();
|
return parseNumber();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +32,9 @@ export const jsonParse = (jsonStr) => {
|
||||||
if (jsonStr[index] === ',') {
|
if (jsonStr[index] === ',') {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
while (jsonStr[index] === ' ' || jsonStr[index] === '\n') {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -47,6 +53,9 @@ export const jsonParse = (jsonStr) => {
|
||||||
}
|
}
|
||||||
function parseString() {
|
function parseString() {
|
||||||
let str = '';
|
let str = '';
|
||||||
|
while(jsonStr[index] === ' ' || jsonStr[index] === '\n'){
|
||||||
|
index++;
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
while (jsonStr[index] !== '"') {
|
while (jsonStr[index] !== '"') {
|
||||||
str += jsonStr[index];
|
str += jsonStr[index];
|
||||||
|
|
|
@ -257,8 +257,7 @@ export default {
|
||||||
if (this.body.format === 'JSON-SCHEMA') {
|
if (this.body.format === 'JSON-SCHEMA') {
|
||||||
if (this.body.raw) {
|
if (this.body.raw) {
|
||||||
try {
|
try {
|
||||||
const tmpStr = trimAll(this.body.raw)
|
const tmpObj = jsonParse(this.body.raw)
|
||||||
const tmpObj = jsonParse(tmpStr)
|
|
||||||
this.body.jsonSchema = MsConvert.format(tmpObj);
|
this.body.jsonSchema = MsConvert.format(tmpObj);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.body.format = 'JSON';
|
this.body.format = 'JSON';
|
||||||
|
|
Loading…
Reference in New Issue