如何从空手道中的 json 数组中提取响应
How can I extract response from json array in Karate
我正在尝试提取 response[0].otpValue
但它不起作用
我尝试过:
get[0] response.id
response[0].otpValue
{
"errorCode": null,
"response": [
{
"createdTimestamp": 1557314537720,
"lastUpdatedTimestamp": 1557314537720,
"createdBy": null,
"lastUpdatedBy": null,
"otpValue": "5346",
"expiryTimestamp": 1556807308797,
"validNow": false,
"sessionUserId": null
}
],
"status": "SUCCESS",
"errorMessage": null
}
我希望从上面得到 otpValue json 响应
* def firstOtp = response[0].id
* def answer = { "errorCode": null, "response": [ { "createdTimestamp": 1557314537720, "lastUpdatedTimestamp": 1557314537720, "createdBy": null, "lastUpdatedBy": null, "otpValue": "5346", "expiryTimestamp": 1556807308797, "validNow": false, "sessionUserId": null } ], "status": "SUCCESS", "errorMessage": null }
* def firstOtp = answer.response[0].otpValue
* match firstOtp == "5346"
我正在尝试提取 response[0].otpValue
但它不起作用
我尝试过:
get[0] response.id
response[0].otpValue
{
"errorCode": null,
"response": [
{
"createdTimestamp": 1557314537720,
"lastUpdatedTimestamp": 1557314537720,
"createdBy": null,
"lastUpdatedBy": null,
"otpValue": "5346",
"expiryTimestamp": 1556807308797,
"validNow": false,
"sessionUserId": null
}
],
"status": "SUCCESS",
"errorMessage": null
}
我希望从上面得到 otpValue json 响应
* def firstOtp = response[0].id
* def answer = { "errorCode": null, "response": [ { "createdTimestamp": 1557314537720, "lastUpdatedTimestamp": 1557314537720, "createdBy": null, "lastUpdatedBy": null, "otpValue": "5346", "expiryTimestamp": 1556807308797, "validNow": false, "sessionUserId": null } ], "status": "SUCCESS", "errorMessage": null }
* def firstOtp = answer.response[0].otpValue
* match firstOtp == "5346"