RouteResult toJSON()

04-25-2019 10:13 AM
New Contributor

We need to convert RouteResult to JSON. When we try RouteResult.toJSON() we get a {} result. We are using JavaScript 4.11. toJSON() does work on the properties (directions, etc.) of RouteResult.

// Example of issue.routeTask.solve(routeParams).then(function (data) {const routeResult = data.routeResults[0];const routeResultJson = routeResult.toJSON();console.log(routeResultJson) /* Result is {} */

Thank, Jay.

0 Kudos
3 Replies
Esri Contributor
0 Kudos
New Contributor

Hi Biraja,

Thanks for the quick response! We did see this community link and unfortunately, it does not address our question.

The solution it provides actually does not address using toJSON on a RouteResult. It addresses turning the route property of a RouteResult to JSON. The solution is also using.JSON.stringify (not toJSON()).

We are trying to convert the RouteResult using the toJSON() method. We did try JSON.stringify and it returned "{}" as well.

We need to know if we are doing something wrong or the RouteResult object itself cannot be converted to JSON, only the properties.

Thanks, Jay.

0 Kudos
Esri Regular Contributor

Hi there, 

This issue will be fixed at version 4.12 which will be released end of June, 2019.

0 Kudos