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.
Have you checked the below community link:
https://community.esri.com/thread/225679-routeresulttojson-returns-empty-object-in-arcgis-49
Biraja
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. https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#to....
Thanks, Jay.
Hi there,
This issue will be fixed at version 4.12 which will be released end of June, 2019.