Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Startup Failure with Json read Error

This was suppose to an easy fix, it however proving very elusive. I keep getting the error

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.

I working on an .net core web app. I have two web apps in the same solution. I moved the appsettins file from the working Web app to the one giveing the problem and the situation is still the same. Cant figure out what I am missing

below is my appsettings.json file

{
  "Data": {
    "UserDbConn": {
      "connString": "Server=DbServer;Database=BookDB;    Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  },
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
like image 584
Tee-Jay Avatar asked Dec 05 '25 10:12

Tee-Jay


1 Answers

I came across the same problem. In my case, I'd started implementing app secrets but left it halfway through. My secrets.json file was left linked but with invalid JSON.

Check your .csproj to see if a <UserSecretId> property is set under <PropertyGroup>. If it's set, BuildWebHost() will look through your secrets.json file in '%APPDATA%\Microsoft\UserSecrets\{secretId}', in addition to your appsettings.json file. An error in either file will cause the method to fail, but it won't tell you which file it is.

The solutions in my case were either to remove the <UserSecretId> property or

like image 90
Steepmountain Avatar answered Dec 08 '25 01:12

Steepmountain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!