question

BurrMontana-1715 avatar image
0 Votes"
BurrMontana-1715 asked GiftA-MSFT commented

Bing Maps Distance Matrix REST API not generating valid JSON

Hi,

I'm getting the following JSON in response to a request:

{"isAccepted":true,"isCompleted":true,"requestId":"6bd063f3-c92e-45d1-91df-4bfae8eed2f6","callbackInSeconds":-1,"timeToService":3797.1220000000003,"origins":[{"latitude":40.2706070016233,"longitude":-111.673560973143},{"latitude":123.456,"longitude":123.456},],"destinations":[{"latitude":40.2520318116979,"longitude":-111.649294144464},{"latitude":123.456,"longitude":123.456},],"results":[{"originIndex":0,"destinationIndex":0,"travelDistance":4.471,"travelDuration":11.2,"departureTime":"2021-03-31T16:45:42.3366400+00:00"},{"originIndex":0,"destinationIndex":1,"hasError":true,"errorMessage":"No route found.","travelDistance":-1,"travelDuration":-1,"departureTime":"2021-03-31T16:45:42.3366400+00:00"},{"originIndex":1,"destinationIndex":0,"hasError":true,"errorMessage":"No route found.","travelDistance":-1,"travelDuration":-1,"departureTime":"2021-03-31T16:45:42.3366400+00:00"},{"originIndex":1,"destinationIndex":1,"travelDistance":0,"travelDuration":0,"departureTime":"2021-03-31T16:45:42.3366400+00:00"},]}

This JSON is invalid because of the trailing comma at the very end. Is there any way to fix this problem in Python?


azure-bing-custom
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thanks for reaching out. I suggest you try replacing the commas with an empty string before parsing.

0 Votes 0 ·

Hi, following up. Were you able to try the suggestion above?

0 Votes 0 ·

0 Answers