我收到错误:
undefined:1
'{"completed_in":0.078,"max_id":333655176038719488,"max_id_str":"3336551760387
^
SyntaxError: Unexpected token '
at Object.parse (native)
at /home/tweets/10seconds.js:25:25
at passBackControl (/home/tweets/node_modules/oauth/lib/oauth.js:367:11)
at IncomingMessage.<anonymous> (/home/tweets/node_modules/oauth/lib/oauth.js:386:9)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:895:16
at process._tickCallback (node.js:415:13)
从搜索 API 解析 Twitter API JSON 时。
我正在使用解析这个 JSON 的代码是:
MongoClient.connect("mongodb://localhost:27017/db", function(err, db) {
if(err) { return console.dir(err); }
var collection = db.collection("tweets");
while(run < 200){
oa.get("http://search.twitter.com/search.json?q=morning&rpp=100&include_entities=true&result_type=mixed", access_token, access_token_secret, function(error, data) {
var theTweets = JSON.parse(sys.inspect(data));
collection.insert(theTweets, {w:1}, function(err, result) {});
console.log(run);
});
run = run + 1;
}
});
什么可能导致这种情况?