fix(接口测试): 修复请求体字符串空格丢失问题
This commit is contained in:
parent
cc2dace12e
commit
95c1a1af3f
|
@ -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];
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue