我有一个JSON数组JsonArray.toString(0)
,其值为:
{
"html_instructions": "Head <b>west</b> on <b>Park St</b> toward <b>Glenferrie Rd</b>/<b>State Route 19</b>",
"duration": {
"value": 40,
"text": "1 min"
},
"distance": {
"value": 109,
"text": "0.1 km"
},
"end_location": {
"lng": 145.0358882,
"lat": -37.8197498
},
"polyline": {
"points": "huyeF}pftZIjAC`@MdC"
},
"travel_mode": "DRIVING",
"start_location": {
"lng": 145.0371141,
"lat": -37.8198945
}
}
我怎样才能从中提取第一个元素?即。 “html_instructions”。
答案 0 :(得分:0)
您需要先获取第0个索引的JSON对象,然后才能找到该元素。
试试这个:
jsonArray.getJSONObject(0).get("html_instruction")