如何从此JSON检索值?

时间:2019-05-14 04:24:53

标签: json vbscript asp-classic

我正在使用经典的ASP和JSON。我已经解析了它,并且想要一些有关如何从中检索值的帮助。

我正在使用以下结构从JSON中检索“目标”值,其中“ j”是lopp变量(JSON有很多值,但我只输入了一个):

hgoals = car.Data.get(j).homeTeamInfo.homeGoals 

请问如何从Odds-> Full Time-> regular-> odds-> decimalValue中检索值?谢谢!

JSON文件如下:

{
  "Success": true,
  "Status": "Ok",
  "Data": [
    {
      "timeLive": "FT",
      "matchID": "FECD61",
      "halfTimeScore": "0 - 1",
      "fullTimeScore": "1 - 1",
      "firstTeamToScore": "Away",
      "city": "Ibague",
      "hasLineupAvaliable": true,
      "homeTeamInfo": {
        "homeTeam": "Deportes Tolima",
        "homeGoals": "1",
        "homeGoalsHalfTime": "0",
        "homeCorners": "4",
        "homeYellowCards": "1",
        "homeRedCards": "0",
        "homeShotsOnTarget": "5",
        "homeShotsOffTarget": "9",
        "homeAttacks": "0",
        "homeDangerousAttack": "0",
        "homePossession": "53",
        "homeFouls": 14,
        "avgGoalsHome": 2.4,
        "avgFirstGoalTimeHome": 19.6,
        "avgCornersHalfTime": 5.2,
        "avgCornersFullTime": 10.2,
        "teamID": "456B5",
        "homeTeamForm": null
      },
      "awayTeamInfo": {
        "awayTeam": "Deportivo Cali",
        "awayGoals": "1",
        "awayGoalsHalfTime": "1",
        "awayCorners": "5",
        "awayYellowCards": "3",
        "awayRedCards": "0",
        "awayShotsOnTarget": "4",
        "awayShotsOffTarget": "7",
        "awayAttacks": "0",
        "awayDangerousAttack": "0",
        "awayPossession": "47",
        "awayFouls": 13,
        "avgGoalsAway": 2.4,
        "avgFirstGoalTimeAway": 45.5,
        "avgCornersHalfTime": 4.7,
        "avgCornersFullTime": 8.3,
        "teamID": "456B7",
        "awayTeamForm": null
      },
      "head2head": {
        "draws": 5,
        "homeWins": 7,
        "awayWins": 7,
        "avgGolsH2H": 2.4
      },
      "matchEvents": [
        {
          "eventName": "Card",
          "eventType": "Yellow card",
          "eventTeam": "Away",
          "eventTime": 88,
          "eventPlayer": {
            "playerName": "Yeison Tolosa",
            "playerShortName": "Y. Tolosa",
            "playerID": "205E5F"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": false
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Away",
          "eventTime": 87,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Matías Cabrera",
            "playerShortName": "M. Cabrera",
            "playerID": "76F7F"
          },
          "eventSubOut": {
            "playerName": "Agustín Palavecino",
            "playerShortName": "A. Palavecino",
            "playerID": "20E2C1"
          },
          "eventHomeTeam": false
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Home",
          "eventTime": 83,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Diego Valdes",
            "playerShortName": "D. Valdes",
            "playerID": "205C19"
          },
          "eventSubOut": {
            "playerName": "Luis Daniel Gonzalez",
            "playerShortName": "L. D. Gonzalez",
            "playerID": "83DBD"
          },
          "eventHomeTeam": true
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Away",
          "eventTime": 78,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Yeison Tolosa",
            "playerShortName": "Y. Tolosa",
            "playerID": "205E5F"
          },
          "eventSubOut": {
            "playerName": "Carlos Mario Rodríguez",
            "playerShortName": "C. M. Rodríguez",
            "playerID": "1D7B3D"
          },
          "eventHomeTeam": false
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Home",
          "eventTime": 74,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Larry Vásquez",
            "playerShortName": "L. Vásquez",
            "playerID": "1D2DA9"
          },
          "eventSubOut": {
            "playerName": "Rafael Carrascal",
            "playerShortName": "R. Carrascal",
            "playerID": "1D24E7"
          },
          "eventHomeTeam": true
        },
        {
          "eventName": "Goal",
          "eventType": "Goal",
          "eventTeam": "Home",
          "eventTime": 70,
          "eventPlayer": {
            "playerName": "Marco Pérez",
            "playerShortName": "M. Pérez",
            "playerID": "5980F"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": true
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Away",
          "eventTime": 70,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Didier Delgado",
            "playerShortName": "D. Delgado",
            "playerID": "F033F"
          },
          "eventSubOut": {
            "playerName": "John Mosquera",
            "playerShortName": "J. Mosquera",
            "playerID": "16357B"
          },
          "eventHomeTeam": false
        },
        {
          "eventName": "Substitution",
          "eventType": "Substitution",
          "eventTeam": "Home",
          "eventTime": 46,
          "eventPlayer": null,
          "eventSubIn": {
            "playerName": "Jaminton Campaz",
            "playerShortName": "J. Campaz",
            "playerID": "1EECDD"
          },
          "eventSubOut": {
            "playerName": "Carlos Robles",
            "playerShortName": "C. Robles",
            "playerID": "F1513"
          },
          "eventHomeTeam": true
        },
        {
          "eventName": "Goal",
          "eventType": "Goal",
          "eventTeam": "Away",
          "eventTime": 30,
          "eventPlayer": {
            "playerName": "Carlos Mario Rodríguez",
            "playerShortName": "C. M. Rodríguez",
            "playerID": "1D7B3D"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": false
        },
        {
          "eventName": "Card",
          "eventType": "Yellow card",
          "eventTeam": "Home",
          "eventTime": 24,
          "eventPlayer": {
            "playerName": "Julián Quiñones",
            "playerShortName": "J. Quiñones",
            "playerID": "7FEA3"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": true
        },
        {
          "eventName": "Card",
          "eventType": "Yellow card",
          "eventTeam": "Away",
          "eventTime": 11,
          "eventPlayer": {
            "playerName": "John Mosquera",
            "playerShortName": "J. Mosquera",
            "playerID": "16357B"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": false
        },
        {
          "eventName": "Card",
          "eventType": "Yellow card",
          "eventTeam": "Away",
          "eventTime": 8,
          "eventPlayer": {
            "playerName": "Juan Angulo",
            "playerShortName": "J. Angulo",
            "playerID": "5512B"
          },
          "eventSubIn": null,
          "eventSubOut": null,
          "eventHomeTeam": false
        }
      ],
      "votosMatchWin": {
        "homeWinPercentage": "58.90",
        "drawPercentage": "29.54",
        "awayWinPercentage": "11.57"
      },
      "referee": {
        "name": "Jhon Alexander Ospina Londono",
        "yellowCardsPerGame": "6.33",
        "redCardsPerGame": "0.30"
      },
      "league": {
        "name": "Primera A, Apertura",
        "leagueID": "4811D",
        "region": "Colombia"
      },
      "country": {
        "name": "Colombia",
        "flag": "colombia"
      },
      "stadium": {
        "name": "Estadio Manuel Murillo Toro",
        "capacity": 33000
      },
      "startTime": "2019-05-14T00:45:00Z",
      "startTimeStamps": 1557794700,
      "syncTime": "2019-05-14T02:44:37.565Z",
      "syncTimeStamps": 1557801877,
      "odds": [
        {
          "name": "Full time",
          "regular": [
            {
              "handicap": null,
              "odds": [
                {
                  "decimalValue": "2.10",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "1"
                },
                {
                  "decimalValue": "3.00",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "X"
                },
                {
                  "decimalValue": "3.50",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "2"
                }
              ]
            }
          ],
          "live": [
            {
              "odds": [
                {
                  "decimalValue": "21.00",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "1"
                },
                {
                  "decimalValue": "1.020",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "X"
                },
                {
                  "decimalValue": "21.00",
                  "fractionalValue": null,
                  "americanValue": null,
                  "choice": "2"
                }
              ]
            }
          ],

1 个答案:

答案 0 :(得分:-1)

您可以使用此xpath到达十进制值键:

$.Data[0].odds[0].regular[0].odds[0].decimalValue

这里,每个“ [0]”应等于“ [i]”,其中i是for循环变量。另外,在此路径上:

$.Data[0].odds[0]

您可以检索键“名称”并确定它是否是“全职”。