我正在使用PhpStorm自动化我的API测试。我有一个类似的响应数据格式:
{"status":"OK","result":{"data":[{"id":2,"name":"store","slug":"store"},
{"id":51,"name":"store-1","slug":"store-1"},{"id":76,"name":"store-2","slug":"store-2"},
{"id":60,"name":"test-drive","slug":"Test Drive"},
{"id":52,"name":"commencal","slug":"Commencal"}]}}
[从这里,我想读取name数据以进行如下测试API的比较
client.test("check_store", function() {
client.assert(response.body.data.name=== "store", "store not found");
});
我不确定response.body.data.name
的格式。有没有人帮我做到这一点。
我已经解决了问题,并希望与他人分享。编写以下语句后,问题已解决。response.body.result.data [0]。名称