英文:
How to extract json Response in rest assured with points in key
问题
要从第一个响应中提取状态,你只需使用 one.response
或 two.response
。
对于第二个响应,如果你想提取相同的值(而不更改键),可以这样做:
- 对于 "something.one.txt",你可以使用
something.one.txt.response
。 - 对于 "somethinganother.two.txt",你可以使用
somethinganother.two.txt.response
。
英文:
To extract status form this response in rest assured i just need to use one.response
or two.response
{
"one": {
"status": "SUCCESSFUL",
"fileNum": "1"
},
"two": {
"status": "SUCCESSFUL",
"fileNum": "2"
}}
But how can I extract the same value (without changing key) if i have such response:
{
"something.one.txt": {
"status": "SUCCESSFUL",
"fileNum": "1"
},
"somethinganother.two.txt": {
"status": "SUCCESSFUL",
"fileNum": "2"
}}
答案1
得分: 0
你需要对键进行转义:
response.jsonPath().getString("'something.one.txt'.status") // 将返回 "SUCCESSFUL"
英文:
You need to escape the key:
response.jsonPath().getString("'something.one.txt'.status") // Will return "SUCCESSFUL"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论