-4

How to parse below JSON with the help of volley library, i want distance and duration values.I am new in 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"
    }
Rohan Kadu
  • 1,311
  • 2
  • 12
  • 22

1 Answers1

0

You may use Gson library for that. Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. for more refer this https://github.com/google/gson

For Gson With volley, you may get lots of examples on the internet just google it. some of the link

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

Munir
  • 2,548
  • 1
  • 11
  • 20