【发布时间】:2017-05-31 22:30:25
【问题描述】:
这被认为是一个简单的修复,但事实证明它非常难以捉摸。我不断收到错误
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 应用程序。我将 appettins 文件从工作的 Web 应用程序移到了出现问题的应用程序中,但情况仍然相同。 无法弄清楚我错过了什么
下面是我的 appsettings.json 文件
{
"Data": {
"UserDbConn": {
"connString": "Server=DbServer;Database=BookDB; Trusted_Connection=True;MultipleActiveResultSets=true"
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
【问题讨论】:
-
BookDB和Trusted_Connection之间的空格是空格还是某种不可读的空白字符? -
这只是一个格式问题。实际代码不包含那个空格
-
我通过查看连接字符串解决了类似的错误,有类似
servername\instancename的内容。然后我用这个servername\\instancename替换它并解决了问题。
标签: json asp.net-core