应用程序启动失败,Json读取错误

应用程序启动失败,Json读取错误,json,asp.net-core,Json,Asp.net Core,这被认为是一个容易解决的问题,但事实证明它非常难以捉摸。我一直在犯错误 An error occurred while starting the application.JsonReaderException: Invalid property identifier character: {. Path '', line 2, position 2.Newtonsoft.Json.JsonTextReader.ParseProperty()FormatException: Could not p

这被认为是一个容易解决的问题,但事实证明它非常难以捉摸。我一直在犯错误

An error occurred while starting the application.JsonReaderException: Invalid property identifier character: {. Path '', line 2, position 2.Newtonsoft.Json.JsonTextReader.ParseProperty()FormatException: Could not parse the JSON file. Error on line number '2': '{{'.Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(bool reload) JsonReaderException: Invalid property identifier character: {. Path '', line 2, position 2.
我正在开发一个.net核心web应用程序。我在同一个解决方案中有两个web应用程序。我将appsettins文件从工作的Web应用程序移动到了给出问题的应用程序,情况仍然是一样的。 我想不出我错过了什么

下面是我的appsettings.json文件

{
  "Data": {
    "UserDbConn": {
      "connString": "Server=DbServer;Database=BookDB;    Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  },
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }

我遇到了同样的问题。在我的例子中,我开始实施应用程序机密,但中途放弃了。我的
secrets.json
文件保持链接,但json无效

检查
.csproj
以查看是否在
下设置了
属性。如果设置了它,
BuildWebHost()
将在
'%APPDATA%\Microsoft\UserSecrets\{secretId}'
中查找
secrets.json
文件,以及
appsettings.json
文件。任何一个文件中的错误都会导致方法失败,但它不会告诉您它是哪个文件


我的解决方案是删除
属性,或者是
BookDB
Trusted\u Connection
之间的空格,只是空格或某种不可读的空白字符?这只是格式问题。实际代码不包含空格,我通过查找连接字符串解决了类似错误,其中有类似的内容
servername\instancename
。然后我用这个
servername\\instancename
替换了它,问题就解决了。