多嵌套json字符串,根据key改value
变量
String accessToken = Bearer aaaa
```java
{
"config": {
"name": "testcase description"
},
"teststeps": [
{
"name": "",
"request": {
"method": "POST",
"url": "xxxx",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Authorization": "Bearer bbbb",
"Connection": "keep-alive",
"Content-Length": "156",
"Content-Type": "application/json",
"Host": "xxxx",
"Postman-Token": "xxx",
"User-Agent": "PostmanRuntime/7.28.4"
},
"cookies": {
"JSESSIONID": "xxxx"
},
"body": {
"chunkCount": xx,
"fileMd5": "x",
"fileName": "xxx",
"fileSize": xx,
"folderName": "xxx",
"partNumber": x,
"uploadStatus": "",
"userId": "xxx"
}
},
"validate": [
{
"check": "status_code",
"assert": "equals",
"expect": 200,
"msg": "assert response status code"
}
]
},
{
"name": "",
"request": {
"method": "POST",
"url": "xxxx",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Authorization": "Bearer cccc",
"Connection": "keep-alive",
"Content-Length": "88",
"Content-Type": "application/json",
"Host": "xxx",
"Postman-Token": "xxx",
"User-Agent": "PostmanRuntime/7.28.4"
},
"cookies": {
"JSESSIONID": "xxx"
},
"body": {
"fileMd5": "xxx",
"fileName": "xx",
"uploadStatus": x
}
},
"validate": [
{
"check": "status_code",
"assert": "equals",
"expect": 200,
"msg": "assert response status code"
}
]
}
]
}
###### 变量accessToken = Bearer aaaa 替换 代码黑体部分 Bearer bbbb 和 Bearer cccc 的效果如下:
{
"config": {
"name": "testcase description"
},
"teststeps": [
{
"name": "",
"request": {
"method": "POST",
"url": "xxxx",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Authorization": "Bearer aaaa",
"Connection": "keep-alive",
"Content-Length": "156",
"Content-Type": "application/json",
"Host": "xxxx",
"Postman-Token": "xxx",
"User-Agent": "PostmanRuntime/7.28.4"
},
"cookies": {
"JSESSIONID": "xxxx"
},
"body": {
"chunkCount": xx,
"fileMd5": "x",
"fileName": "xxx",
"fileSize": xx,
"folderName": "xxx",
"partNumber": x,
"uploadStatus": "",
"userId": "xxx"
}
},
"validate": [
{
"check": "status_code",
"assert": "equals",
"expect": 200,
"msg": "assert response status code"
}
]
},
{
"name": "",
"request": {
"method": "POST",
"url": "xxxx",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Authorization": "Bearer aaaa",
"Connection": "keep-alive",
"Content-Length": "88",
"Content-Type": "application/json",
"Host": "xxx",
"Postman-Token": "xxx",
"User-Agent": "PostmanRuntime/7.28.4"
},
"cookies": {
"JSESSIONID": "xxx"
},
"body": {
"fileMd5": "xxx",
"fileName": "xx",
"uploadStatus": x
}
},
"validate": [
{
"check": "status_code",
"assert": "equals",
"expect": 200,
"msg": "assert response status code"
}
]
}
]
}
```