如何解析appsscript中的json数据

问题描述

我正在尝试从下面我的 appsscript 日志中显示的检索到的 json 数据中提取目标数量

Info    {copyright=NHL and the NHL Shield are registered Trademarks of the National Hockey League. NHL and NHL team marks are the property of the NHL and its teams. © NHL 2021. All Rights Reserved.,stats=[{splits=[{season=20202021,stat={pim=4.0,faceOffPct=0.0,plusMinus=3.0,blocked=1.0,shifts=69.0,penaltyMinutes=4,shots=10.0,shortHandedTimeOnIcePerGame=01:59,shotPct=10.0,games=3.0,shortHandedTimeOnIce=05:59,shortHandedGoals=0.0,gameWinningGoals=0.0,overTimeGoals=0.0,powerPlayTimeOnIcePerGame=02:51,powerPlayTimeOnIce=08:34,timeOnIcePerGame=17:31,assists=2.0,timeOnIce=52:33,evenTimeOnIce=38:00,powerPlayPoints=0.0,shortHandedPoints=0.0,evenTimeOnIcePerGame=12:40,goals=1.0,powerPlayGoals=0.0,points=3.0,hits=3.0}}],type={gameType={id=R,description=Regular season,postseason=false},displayName=statsSingleSeason}}]}

我使用的 appscript 代码是:

function update() {
  var response = UrlFetchApp.fetch("https://statsapi.web.nhl.com/api/v1/people/8473986/stats?stats=statsSingleSeason&season=20202021");
  var json = response.getContentText();
  var data = JSON.parse(json);
  Logger.log(data);
  Logger.log(data.stats.goals);
}

如何根据应用脚本日志图像(上图)中显示的数据记录目标?

感谢您的帮助!

解决方法

终于明白了。

Logger.log(result.stats[0].splits[0].stat.goals); 

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...