我使用的是Google AdWords / App脚本,我收到了DoubleClick Search的回复。我试图解析它以将Sheet /放入数组中以便使用,并且我没有太多运气。谢谢你看看。
这是原始代码:
var response = authUrlFetch.fetch(url, options);
var data = JSON.stringify(response.getContentText());
var parsedData = JSON.parse(data);
{
"kind": "doubleclicksearch#report",
"request": {
"reportType": "advertiser",
"columns": [
{
"columnName": "agency"
},
{
"columnName": "agencyId"
},
{
"columnName": "advertiser"
},
{
"columnName": "advertiserId"
}
],
"includeRemovedEntities": false,
"statisticsCurrency": "usd",
"startRow": 0,
"rowCount": 10000
},
"statisticsCurrencyCode": "USD",
"rowCount": 2,
"rows": [
{
"agency": "a",
"agencyId": "11111111111111",
"advertiser": "aa",
"advertiserId": "11111111111111"
},
{
"agency": "b",
"agencyId": "222222222222222",
"advertiser": "bb",
"advertiserId": "22222222222"
}
]
}
答案 0 :(得分:11)
它类似于常规JavaScript。您使用UrlFetchApp服务获得JSON响应,然后使用点表示法访问属性。
var response = authUrlFetch.fetch(url, options);
var data = JSON.parse(response.getContentText());
Logger.log(data.request.reportType);