[Solved] Extract data from nested JSON Node JS


assuming that your JSON is object named data

var data =     {
   "destination_addresses" : [ "Chennai, Tamil Nadu, India" ],
   "origin_addresses" : [ "Kolkata, West Bengal, India" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "1,671 km",
                  "value" : 1671269
               },
               "duration" : {
                  "text" : "1 day 5 hours",
                  "value" : 104370
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
} 

You would access distance element like this

data.rows[0].elements[0].distance

1

solved Extract data from nested JSON Node JS