Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用-in-karate框架Ex:Attribute auth-token获取json值_Json_Testing_Frameworks_Karate - Fatal编程技术网

如何使用-in-karate框架Ex:Attribute auth-token获取json值

如何使用-in-karate框架Ex:Attribute auth-token获取json值,json,testing,frameworks,karate,Json,Testing,Frameworks,Karate,帮助解决下面的问题 变量: * def token = loginResponse.response.data.attributes.auth-token 错误: -未知-:7-javascript评估失败:loginResponse.response.data.attributes.auth-token,ReferenceError: 第1行中未定义“令牌” com.intuit.karate.exception.karateeexception:-未知-:7-javascript 评估失败

帮助解决下面的问题

变量:

* def token = loginResponse.response.data.attributes.auth-token
错误:

-未知-:7-javascript评估失败:loginResponse.response.data.attributes.auth-token,ReferenceError: 第1行中未定义“令牌” com.intuit.karate.exception.karateeexception:-未知-:7-javascript 评估失败:loginResponse.response.data.attributes.auth-token, ReferenceError:“令牌”未在第1行中定义 ✽.* def token=loginResponse.response.data.attributes.auth-token (-未知-:7)

Schemma json:

{
"data": {
    "id": "3326",
    "type": "users",
    "attributes": {
    "email": "emerson@gmail.com",
    "auth-token": "3ve6mPU4G-txLBmvc5eJ",
    "created-at": "2020-04-19T17:30:54.031Z",
    "updated-at": "2020-04-21T17:47:39.649Z"
    }
}
}
请求:

Scenario: List tasks

Given path '/tasks'

And header Accept = " application/vnd.tasksmanager.v2"

And header Authorization = token

When method GET

Then status 200

对于JSON键中的特殊字符,请使用方括号访问:

* def token = loginResponse.response.data.attributes['auth-token']

对于JSON键中的特殊字符,请使用方括号访问:

* def token = loginResponse.response.data.attributes['auth-token']