Как извлечь ответ из массива json в каратэ - PullRequest
1 голос
/ 10 мая 2019

Я пытаюсь извлечь 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 response

* def firstOtp = response[0].id

1 Ответ

1 голос
/ 10 мая 2019
* 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"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...