I’m using Esri JavaScript 4.10.
I have a javascript object with graphics. When I use JSON.stringify the output is weird. On all graphics the symbol ‘type’ is changed; ‘simple-marker’ to ‘esriSMS’, ‘simple-fill’ to ‘esriSFS’, etc.
When I use JSON.parse, those values are not returned to the original. This is causing errors when I try to import it back into the map because ‘new Graphic’ is looking for ‘simple-marker’ while ‘esriSMS’ throws an error.
Does anyone know why JSON.stringify replaces those values? Or does anyone have a better way of stringify-ing an object?
Thanks!
Daniel,
The Graphics class has a toJSON method that you should be using.
https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#toJSON