简体   繁体   中英

.net core: Invalid property identifier character: {. Path 'Logging', line 10, position 2. Newtonsoft.Json.JsonTextReader.ParseProperty()

I added Angular CLI to my project and everything was working. Then I decided to click the little flag at the top in Visual Studio 2017 which indicated that there is a new update for VS 2017. I installed it and restarted my Windows 10 PC.

Now it builds successfully using F6 however I'm getting the following error when I F5 or Ctrl+F5 my .net core mvc application in a browser:

screenshot: https://imgur.com/wFFN1r8

An error occurred while starting the application.

JsonReaderException: Invalid property identifier character: {. Path 'Logging', line 10, position 2. Newtonsoft.Json.JsonTextReader.ParseProperty()

FormatException: Could not parse the JSON file. Error on line number '10': '}, {'. Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(bool reload)

JsonReaderException: Invalid property identifier character: {. Path 'Logging', line 10, position 2. Newtonsoft.Json.JsonTextReader.ParseProperty() Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings) Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options) Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings) Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)

My appsettings.json file looks like:

{
   "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
     }
   }
}

I can't think of any other .json file that would be a problem. I removed the Angular client-app folder I added and it still produces the same error.

I have no clue where to begin with trying to solve this issue and Google isn't bringing up any other posts with the same issue.

Suggestions?

@Jamie Taylor figured it out.

The one file I didn't see since it doesn't appear in Solution Explorer unless you expand appsettings.json is "appsettings.Development.json".

I had:

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  {
    "AWS": {
      "Profile": "Default",
      "Region": "us-east-1"
    }
  }
}

It was working earlier the same day and I can see in my windows file explorer that the file has not changed in the last 2 weeks. The formatting of this JSON file was incorrect. Since I don't need the AWS stuff anymore, I just deleted that part and now it's working as:

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }
}

Please delete ( ) simbols on start and on end positions. It help my.

i get json as

( { result : "" } )

and it work now

{ result : "" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM