如何在排球库的帮助下解析 JSON ,我想要距离和持续时间值。我是Android的新手
{
"destination_addresses":[
"D1, A Block, Sector 59, Noida, Uttar Pradesh 201301, India"
],
"origin_addresses":[
"School Block, Block S1, Nanakpura, Shakarpur Khas, New Delhi, Delhi 110092, India"
],
"rows":[
{
"elements":[
{
"distance":{
"text":"13.8 km",
"value":13751
},
"duration":{
"text":"28 mins",
"value":1674
},
"status":"OK"
}
]
}
],
"status":"OK"
}
答案 0 :(得分:0)
您可以使用Gson
库。 Gson
是一个Java库,可用于将Java对象转换为其JSON表示。它还可用于将JSON字符串转换为等效的Java对象。有关详情,请参阅此https://github.com/google/gson
对于Gson With volley,你可以在互联网上获得大量的例子谷歌。一些链接
http://www.coderzheaven.com/2016/04/10/custom-gson-request-with-volley/ https://inducesmile.com/android/android-json-parsing-using-gson-and-recyclerview/ https://kylewbanks.com/blog/tutorial-parsing-json-on-android-using-gson-and-volley