Javascript 在Expressjs for Parse.com中导航和解析JSON树

Javascript 在Expressjs for Parse.com中导航和解析JSON树,javascript,json,express,parse-platform,Javascript,Json,Express,Parse Platform,目前,一个JSON对象被发送到我的webhook,我正在Parse.com的云主机上构建它 这是阵列: { "name": "Kenpom", "count": 351, "frequency": "Every 15 mins", "version": 211, "newdata": false, "lastrunstatus": "success", "lastsuccess": "Tue Mar 03 2015 21:29:43 GMT+0000 (UTC)",

目前,一个JSON对象被发送到我的webhook,我正在Parse.com的云主机上构建它

这是阵列:

{
  "name": "Kenpom",
  "count": 351,
  "frequency": "Every 15 mins",
  "version": 211,
  "newdata": false,
  "lastrunstatus": "success",
  "lastsuccess": "Tue Mar 03 2015 21:29:43 GMT+0000 (UTC)",
  "thisversionstatus": "success",
  "nextrun": "Wed Mar 04 2015 02:38:00 GMT+0000 (UTC)",
  "thisversionrun": "Tue Mar 03 2015 21:29:23 GMT+0000 (UTC)",
  "results": {
    "collection1": [
      {
        "rank": "1",
        "team": {
          "href": "http://kenpom.com/team.php?team=Kentucky",
          "text": "Kentucky"
        },
        "conference": {
          "href": "http://kenpom.com/conf.php?c=SEC",
          "text": "SEC"
        },
        "currentrecord": "29-0",
        "pyth": ".9792",
        "offensiveefficiency": "118.7",
        "defensiveefficiency": "84.9",
        "tempo": "63.6"
      },
      {
        "rank": "2",
        "team": {
          "href": "http://kenpom.com/team.php?team=Virginia",
          "text": "Virginia"
        },
        "conference": {
          "href": "http://kenpom.com/conf.php?c=ACC",
          "text": "ACC"
        },
        "currentrecord": "28-1",
        "pyth": ".9654",
        "offensiveefficiency": "112.3",
        "defensiveefficiency": "84.0",
        "tempo": "58.2"
      },...
这就是我试图用来接受请求的原因:

// Global app configuration section
app.set('views', 'cloud/views');  // Specify the folder to find templates
app.set('view engine', 'ejs');    // Set the template engine
app.use(express.bodyParser());    // Middleware for reading request body

app.post('/notify_message',
         // express.basicAuth('', ''),
         function(req, res, data) {
  // Use Parse JavaScript SDK to create a new message and save it.
  var Kenpom = Parse.Object.extend("Kenpom");
  var kenpom = new Kenpom();
  kenpom.save({ 
    conference : data,
    rank: data
  }).then(function(kenpom) {
    res.send('Success');
  }, function(error) {
    res.status(500);
    res.send('Error');
  });
});

// Attach the Express app to Cloud Code.
app.listen();
我的请求得到了200分,但在Parse中,我看到的排名和会议值结果都是{}


我的问题是:如何在Express中浏览JSON树,以便获得所有这些团队的JSON对象传递的值

您需要接受请求对象,并将其解析为json:

在开始时使用此选项:

app.use(bodyParser.json());
然后正确处理数据:

function (req, res) {
    req.body // req.body is the object that you received
}

请求主体是否进入kenpom.save?当我把它放进去的时候,我得到了一个错误function@beaconhill尝试执行
console.log(请求正文)
。它应该打印发送给您的JSON对象。这是我正在构建的中间件webhook。它是一个URL,当数据更新时,服务点击该URL向其发送一个JSON对象。我不知道如何调试它。