0
试图解析JSON文件,上面写着这样的: [ { “名称”:“埃里克·西” “DOB”:1994年8月29日 } ] 极品解析该文件,以便mongodb中的该字段名称使用上面的name属性自动填充。阅读JSON文件
这是我想出了:
var url = "http://theurl";
if (Meteor.isServer) {
Meteor.methods({
jsonParse: function() {
this.unblock();
return Meteor.http.call("GET", url, data["Name"]);
}});}
//invoke the server method
if (Meteor.isClient) {
Meteor.call("jsonParse", function(error, results) {
console.log(results.content); //results.data should be a JSON object
});}
您可以使用此模块[jsonfile(https://www.npmjs.com/package/jsonfile)来解析JSON文件 – Khang