これは応答です:
{
"makerCommission": 15,
"takerCommission": 15,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"updateTime": 123456789,
"accountType": "SPOT",
"balances": [
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
},
{
"asset": "LTC",
"free": "4763368.68006011",
"locked": "0.00000000"
}
],
"permissions": [
"SPOT"
]
}
これは私のコードです:
var jsonResponce = JSON.parse(data); // To JSON
Logger.log(jsonResponce.accountType); // Return SPOT
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var rows = [],
balanc;
for (i = 0; i < jsonResponce.length; i++) {
balanc = jsonResponce[i];
rows.push([balanc.accountType]);
}
Logger.log(rows); /////////////// return [] why not return SPOT
dataRange = sheet.getRange(1, 1, rows.length, 1);
dataRange.setValues(rows);
配列なしで実行した場合、JSON は accountType を返しますが、配列を追加した後は、[] が空のヘルプが表示されます。
これは絵です: