Bing Maps Distance Matrix REST API not generating valid JSON

Burr, Montana 1 Reputation point
2021-03-31T23:02:40.83+00:00

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?

Bing Custom Search
Bing Custom Search
An easy-to-use, ad-free, commercial-grade search tool that lets you deliver the results you want.
81 questions
{count} votes