JSON数据/方括号剥离

正在努力通过async.map合并来自多个数据源的数据。 然而,我有一个新的数据结构的问题,这是由多个文件组合成一个…每个logging周围的额外括号。

这是我正常的JSON文档格式如下:

{ "_id": "527b16584930484431f054be", "caption": "lucky", "created_time": "1383652572", "full_name": "kkelcie", }, { "_id": "527b16584930484431f054bd", "caption": "Me with all my friends on our day off work. ", "created_time": "1383798277", "full_name": "zeftodeathbitch" } 

这是他的方式来自多个查询的新数据格式化:

 [ { "_id": "52799ef14930484431ed58ed", "caption": "☀", "created_time": "1383698900", "full_name": "andreSDFFSdfazapata" } ], [ { "_id": "5279a7514930484431ed6b2f", "caption": "Clear Lake", "created_time": "1375497332", "full_name": "SCALLSDFFYSWAG" } ] 

所以….如何去掉每个特定logging周围的方括号? 现在没有任何工作:)

如果我们在这里谈论你的问题,你可能想重写你的查询:

 async.map(arLimit, function(eachrecord, callback){ UGC_DB_Model.findOne().skip(eachrecord).limit(-1).exec(function(err, result) { if (err) { callback(err); } else { callback(null, result); } }); }, function(err, result) { if (err) return next(err); console.log("(it's empty): " + result); }); 

这使用findOne而不是find ; findOne将总是返回(最多)一个结果,而find将返回多个(作为一个数组)。 但是因为你将结果限制为一个,所以findOne更合适。