【发布时间】:2019-06-11 14:17:37
【问题描述】:
需要获取 DisplayName 的 Id 值”:“来自 API 响应的三星 XCover 4 我试过了,但没有用。
var response = JSON.parse(responseBody);
{
var count = Object.keys(response.Offerings[0]);
console.log(count);
for(var x =0; x <=count.length ; x++)
{
if(count[x] == 'Id')
{
var val =
console.log(response.Offerings[0].count[x]);
// console.log(pm.environment.get(count['Id']));
}
}
}
来自 API 的响应:
{
"Offerings": [
{
"Amount": 292,
"CurrencyCode": "CAD",
"DisplayName": "Samsung XCover 4",
"Id": 1910256761716000500,
"Language": "en-CA",
"LineOfBusinesses": [
10048
],
"MarketingViews": [],
"Name": "Samsung XCover 4",
"OfferType": 1,
"ShortDescription": "Offering bundle includes:\n- Airtime Product\n- Samsung XCover 4 device\n- SIM Card\n- & optional device protection",
我有一个 DisplayName 和 Id 的日志列表,但我需要在其他 API 的正文中使用“DisplayName”的 ID:“Samsung XCover 4”。
【问题讨论】: