The following error was encountered: Unexpected token '', "{ "na"... is not valid JSON
SWA Version: 2.0.4
Describe the bug When I run swa deploy or swa I get a JSON validation error, even my JSON's config files for the staticwebapp-config.json are all valid json. With this state I can not deploy a SWA with a config.
To Reproduce
- Place a json with the name "staticwebapp.config.json" in our "app" folder with the content
{} - Run
swa deploy
The following error occurs on my end:
WARNING: Failed to read staticwebapp.config.json configuration from: C:\folder1\folder2\folder3\client\staticwebapp.config.json
✖ The following error was encountered: Unexpected token '', "{}" is not valid JSON Please fix the above error and try again to load and use the configuration. Read more: https://aka.ms/swa/config-schema
At this state the staticwebapp.config.json only contains {}
But I tried configurations like the this one, and they not working too.
{
"navigationFallback": {
"rewrite": "/index.html"
}
}
Error Message:
✖ The following error was encountered: Unexpected token '', "{ "na"... is not valid JSON
Expected behavior Deployment Working
Desktop (please complete the following information):
- OS: Windows
- Version PS7
Additional context Add any other context about the problem here.
The problem is the following: The JSON parser only accepts hardcoded UTF-8 and not UTF-8 with BOM for example. I think It is needed, that the JSON parsers tries multiple encodings.