I am making a program which gets the Json distance matrix from Google Maps API. So far i wrote the program can get the json it looks as below
{
"destination_addresses" : [
"Paris, France",
"Toulon, France",
"Nantes, France",
"Marseille, France"
],
"origin_addresses" : [
"Paris, France",
"Toulon, France",
"Nantes, France",
"Marseille, France"
],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "1 m",
"value" : 0
},
"duration" : {
"text" : "1 min",
"value" : 0
},
"status" : "OK"
},
{
"distance" : {
"text" : "839 km",
"value" : 838906
},
"duration" : {
"text" : "7 hours 21 mins",
"value" : 26476
},
"status" : "OK"
},
{
"distance" : {
"text" : "384 km",
"value" : 384421
},
"duration" : {
"text" : "3 hours 34 mins",
"value" : 12823
},
"status" : "OK"
},
{
"distance" : {
"text" : "774 km",
"value" : 774398
},
"duration" : {
"text" : "6 hours 48 mins",
"value" : 24490
},
"status" : "OK"
}
]
},
Now what i want to do is to create a distance matrix as this
[ Paris Toulon Nantes Marseille ]
[Paris 0 838906 384421 774398 ]
[Toulon value 0 value value]
[Nantes value value 0 value]
[Marseille value value value 0 ]
** The values stands for distance between the cities.
(in java form of course) and later i will use it in solving the TSP. I need the values from Elements --> Distance --> Values. Any help would be appreciated. Thanks in advance.