第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

訪問要存儲在 AWS Dynamo 數(shù)據(jù)庫表中的嵌套 JSON 對象

訪問要存儲在 AWS Dynamo 數(shù)據(jù)庫表中的嵌套 JSON 對象

紅糖糍粑 2023-09-06 16:14:27
我希望訪問休息請求中的嵌套 JSON 對象,以將其存儲為 AWS 上的 Dynamo DB 表中的主鍵。Json 對象的格式如下:{ "api": {    "results": 543,    "fixtures": [      {        "fixture_id": 95095,        "venue": "Estádio Rei Pelé",        "goalsHomeTeam": 1,        "goalsAwayTeam": 1,        "awayTeam": {          "logo": "https://media.api-football.com/teams/156.png",          "team_id": 156,          "team_name": "Sao Bento"        },        "event_timestamp": 1569715200,        "referee": null,        "elapsed": 90,        "score": {          "halftime": "0-0",          "penalty": null,          "fulltime": "1-1",          "extratime": null        },        "round": "Regular Season - 25",        "event_date": "2019-09-29T00:00:00+00:00",        "statusShort": "FT",        "homeTeam": {          "logo": "https://media.api-football.com/teams/146.png",          "team_id": 146,          "team_name": "CRB"        },我正在嘗試使用以下代碼訪問它,但我NullPointerException在第 38 行上得到了一條信息,即以下開始的行int fixture_id。我的代碼如下:JsonParser parser = new JsonFactory().createParser(new File("fixturesTwo.json"));    JsonNode rootNode = new ObjectMapper().readTree(parser);    Iterator<JsonNode> iter = rootNode.iterator();    ObjectNode currentNode;    while (iter.hasNext()) {        currentNode = (ObjectNode) iter.next();        int fixture_id = currentNode.path("api").findPath("fixtures").findValue("fixture_id").asInt();        int league_id = currentNode.path("api").findPath("fixtures").findValue("league_id").asInt();我猜這與我正在做的事情類似,我只是不知道我做錯了什么。
查看完整描述

1 回答

?
料青山看我應如是

TA貢獻1772條經(jīng)驗 獲得超8個贊

rootNode 有節(jié)點“API”。currentNode:


{

   "results":543,

   "fixtures":[

      {

         "fixture_id":95095,

         "venue":"Estádio Rei Pelé",

         "goalsHomeTeam":1,

         "goalsAwayTeam":1,

         "awayTeam":{

            "logo":"https://media.api-football.com/teams/156.png",

            "team_id":156,

            "team_name":"Sao Bento"

         },

         "event_timestamp":1569715200,

         "referee":null,

         "elapsed":90,

         "score":{

            "halftime":"0-0",

            "penalty":null,

            "fulltime":"1-1",

            "extratime":null

         },

         "round":"Regular Season - 25",

         "event_date":"2019-09-29T00:00:00+00:00",

         "statusShort":"FT",

         "homeTeam":{

            "logo":"https://media.api-football.com/teams/146.png",

            "team_id":146,

            "team_name":"CRB"

         }

      }

   ]

}

正確的代碼:


int fixture_id = currentNode.path("fixtures").findValue("fixture_id").asInt();


查看完整回答
反對 回復 2023-09-06
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號