Android Question JSON Parser error with Google Maps Distance Matrix API

qle

Member
Licensed User
Longtime User
Hi,
I seem to have an issue with parsing data returned by Google Maps Distance Matrix API

It may be something im doing wrong, but if i try to map data,
B4X:
                Dim parser As JSONParser
                parser.Initialize(GoogleJson_RetunedString)
                Log(parser.NextObject) 'just to have a peek
                    Dim m As Map
                    m = parser.NextObject 'thows error
i get error " at org.json.JSONTokener.syntaxError(JSONTokener.java:450)"

where the GoogleJson_RetunedString is
B4X:
{
   "destination_addresses" : [ "103 Birddog St, Binnaloop WA 6218, Australia" ],
   "origin_addresses" : [ "62 Android Dr, Kingsway WA 6226, Australia" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "11.1 km",
                  "value" : 11135
               },
               "duration" : {
                  "text" : "12 mins",
                  "value" : 739
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

I have parsed the data using other platforms, and the data is valid.
So i guess im doing something wrong in A4B.

Best regards
Lee.
 

qle

Member
Licensed User
Longtime User
Ahhh... yes it was the log(parser.NextObject) that caused the issue...
i missed that!

Btw... Great tool!
 
Last edited:
Upvote 0
Top