【发布时间】:2017-01-04 22:22:52
【问题描述】:
我有这个 JSON
{
"_id": "586baa68734d1d7bf4f06432",
"topic": 1,
"story": {
"2016-01-01": 152,
"2016-01-02": 203,
"2016-01-03": 419,
"2016-01-04": 792,
"2016-01-05": 457,
"2016-01-06": 350,
"2016-01-07": 666
}
}
这个函数打印出这个 JSON
exports.getData = function(req, res){
Top10.find({},function(err, docs){
console.log("docs "+docs);
res.json(docs);
});
}
现在我想获取特定日期的 NUMBER - 比如说 2016-01-01 我想取回 152
我该怎么做?
【问题讨论】:
-
docs["story"]["2016-01-01"] -
@JonasKöritz 感谢您的回答!我试过 console.log("docs "+docs["story"]['2016-01-01']);它仍然无法正常工作