姬長信(Redy)

解析JSON文件Java


参见英文答案 > How to parse JSON in Java????????????????????????????????????31个
我想在java中解析一个JSON文件,并从下面提到的文件中获取以下值:
{
  "status": "OK",
  "origin_addresses": [ "Vancouver, BC, Canada", "Seattle, ?tat de Washington, ?tats-Unis" ],
  "destination_addresses": [ "San Francisco, Californie, ?tats-Unis", "Victoria, BC, Canada" ],
  "rows": [ {
    "elements": [ {
      "status": "OK",
      "duration": {
        "value": 340110,
        "text": "3 jours 22 heures"
      },
      "distance": {
        "value": 1734542,
        "text": "1 735 km"
      }
    }, {
      "status": "OK",
      "duration": {
        "value": 24487,
        "text": "6 heures 48 minutes"
      },
      "distance": {
        "value": 129324,
        "text": "129 km"
      }
    } ]
  }, {
    "elements": [ {
      "status": "OK",
      "duration": {
        "value": 288834,
        "text": "3 jours 8 heures"
      },
      "distance": {
        "value": 1489604,
        "text": "1 490 km"
      }
    }, {
      "status": "OK",
      "duration": {
        "value": 14388,
        "text": "4 heures 0 minutes"
      },
      "distance": {
        "value": 135822,
        "text": "136 km"
      }
    } ]
  } ]
}

从每个元素,我想得到距离和持续时间的值字段.我该怎么做呢?