Uncaught SyntaxError: Bad escaped character in JSON at position 97', filename: 'blob:http://localhost:4201/c708361e-0008-48a9-95b9-c955556554e8'
I have debugged this error to being the applicationURL in the config JSON that the worker tries to parse which has a single and double \ in the (original) URL. The config is trying to escape the \ which results in '\\\\' and '\\' respectively, but as this is JSON inside JS, it requires 8 slashed instead of 4 to parse. See the attached fiddle with the current code and the working code.
Solved! Go to Solution.
I narrowed it down to JSON.parse() not liking the double backslash \\.
When the user opens a url: http://localhost:5173/?locale=fr&config=assets\config\config.json what gets input into the applicationURL of esriConfig is http://localhost:5173/?locale=fr&config=assets\\config\\config.json. My workaround is to use the following url: http://localhost:5173/?locale=fr&config=assets%5cconfig%5cconfig.json however, it is less user-readable and depends on user validation.
Is it possible for you to modify your code to encodeURI(window.location.href) as the value you put into applicationURL so this exception will not happen in most case-scenarios?
Hi @ConnerFarrant are you building a custom ArcGIS JS API app or using an ArcGIS Dashboard? If you are using a Dashboard, you'll need to follow that product's System Requirements and Tech Support procedures. Here's a link to the ArcGIS Dashboard community site if you need to reach out to them for more guidance.
This is a JS App, simply trying to display a map on the page and dynamically pass through the lat, long etc. This issue is caused by the URL string.
If it's a custom JS app we will need a link to a simple github repo, codesandbox or stackblitz.com sample. If you need a basic Angular + ArcGIS JS API sample as a starting point, we recommend using this one: https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-angular-cli.
I have this same issue. It does not correctly parse the = character because if I replace the value with %3d in the URL it will work fine. Has anyone looked into this issue? Does esriConfig require the full URL in applicationURL or can it take the URL before the querystring?
I narrowed it down to JSON.parse() not liking the double backslash \\.
When the user opens a url: http://localhost:5173/?locale=fr&config=assets\config\config.json what gets input into the applicationURL of esriConfig is http://localhost:5173/?locale=fr&config=assets\\config\\config.json. My workaround is to use the following url: http://localhost:5173/?locale=fr&config=assets%5cconfig%5cconfig.json however, it is less user-readable and depends on user validation.
Is it possible for you to modify your code to encodeURI(window.location.href) as the value you put into applicationURL so this exception will not happen in most case-scenarios?
Quite old question but yes, that was essentially the solution (can't remember exactly). I seem to have created a wrapper component to hold the ArcGIS map which handled all the encoding and parsing as I could not do it directly with the ArcGIS map due to the JSON parsing issue. Hopefully this helps you out too.