如何从下面的json响应有效负载中提取auth令牌以用于后续请求(似乎我遇到了麻烦,因为键值中的键有双引号)?
功能:
test oauth
背景: *网址https://xxx.yyy.com
场景:Get xxx-subject
给定路径xxx/oauth/internal/proof/srvc
和标题someData
方法get
时 然后状态200
并打印'authorization :'$[2]
响应有效负载:
{
"xxx-gateway-proof":"xxxx",
"xxx-subject":" yyy",
"authorization":"Bearer zzz"
}
答案 0 :(得分:0)
不是双引号,连字符-
符号会导致JSON键出现问题,因为它被解释为减号。
我刚刚测试了下面的内容,它有效:
* def response =
"""
{
"xxx-gateway-proof": "xxxx",
"xxx-subject":" yyy",
"authorization": "Bearer zzz"
}
"""
* def proof = response['xxx-gateway-proof']
* match proof == 'xxxx'