-3
我正在嘗試使用JSON.stringify
來使我的json對象可讀。
但是,它不起作用。任何人都可以幫助我看看我做錯了什麼嗎?json的輸出不正確
var request = require('request');
var options = {
url: 'https://api.github.com/repos/benjaminsunderland/TicTacToe/stats/commit_activity',
headers: {
'User-Agent': 'request'
}
};
function callback(error, response, body) {
console.log(JSON.stringify(body, null, 2));
}
request(options, callback);
輸出應沿着線:根據文件
[
{
"days": [
0,
3,
26,
20,
39,
1,
0
],
"total": 89,
"week": 1336280400
}
]
:
https://developer.github.com/v3/repos/statistics/
但是,我得到:
"[{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1483232400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1483837200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1484442000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1485046800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1485651600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1486256400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1486861200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1487466000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1488070800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1488675600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1489280400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1489881600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1490486400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1491091200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1491696000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1492300800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1492905600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1493510400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1494115200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1494720000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1495324800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1495929600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1496534400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1497139200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1497744000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1498348800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1498953600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1499558400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1500163200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1500768000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1501372800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1501977600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1502582400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1503187200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1503792000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1504396800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1505001600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1505606400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1506211200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1506816000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1507420800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1508025600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1508630400},{\"days\":[0,0,0,0,5,2,6],\"total\":13,\"week\":1509235200},{\"days\":[1,0,0,0,0,0,0],\"total\":1,\"week\":1509840000},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1510444800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1511049600},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1511654400},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1512259200},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1512864000},{\"days\":[0,1,0,0,0,0,0],\"total\":1,\"week\":1513468800},{\"days\":[0,0,0,0,0,0,0],\"total\":0,\"week\":1514073600}]"
什麼是你想要的輸出格式? –
對不起,我的問題嚴重。我現在編輯它。 – slayallevil