core icon indicating copy to clipboard operation
core copied to clipboard

Could not parse the JSON file

Open beefsteak opened this issue 7 years ago • 23 comments

1.Create new worker service project. 2.Debug is error, but run is right. image

beefsteak avatar Nov 02 '19 11:11 beefsteak

what does your json file look like?

scalablecory avatar Nov 04 '19 05:11 scalablecory

@scalablecory image image image image image

beefsteak avatar Nov 04 '19 05:11 beefsteak

@scalablecory All net core projects that contain the appsetting file report the same error.

beefsteak avatar Nov 04 '19 05:11 beefsteak

@scalablecory But running without debugging does not cause errors

beefsteak avatar Nov 04 '19 05:11 beefsteak

Looks like a BOM problem. Did this happen by default?

davidfowl avatar Nov 04 '19 05:11 davidfowl

yes,it happen by default

beefsteak avatar Nov 04 '19 05:11 beefsteak

Appseting.json default format is utf-8 image

beefsteak avatar Nov 04 '19 05:11 beefsteak

@scalablecory Does this error have anything to do with net core built-in system.text.json component

beefsteak avatar Nov 04 '19 05:11 beefsteak

@scalablecory That's fine if project sdk is net core 2.2. So my guess is that net core 3.0 caused the problem

beefsteak avatar Nov 04 '19 11:11 beefsteak

Thanks for the detail. We'll need to take a look at the file to know for sure, but it's possible.

scalablecory avatar Nov 04 '19 22:11 scalablecory

@davkean @Pilchie possible VS template or appsettings parser issue, can you help route this to the right people?

scalablecory avatar Nov 04 '19 22:11 scalablecory

if it's templates, that would depend on the exact template. If it's System.Text.Json then corefx. @ahsonkhan for S.T.J...

Pilchie avatar Nov 05 '19 01:11 Pilchie

I tried to repro the issue on .NET Core 3.0 and couldn't (TFM netcoreapp3.0 with <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />). Same with .NET Core 3.1 (even if I explicitly save the appsettings json file to UTF-8 with BOM).

@beefsteak, can you share a copy of your project that is showing the error? What version of VS are you using?

When I create a new worker service (using VS Version 16.4.0 Preview 3.0), the appsettings.json file doesn't contain a BOM so I don't see why the file you are seeing would start with a 0xEF byte.

There was a BOM issue with the JsonSerializer that was fixed for 3.1 (that is if the JSON file did contain a BOM marker), but I can't tell if that is relevant here without a repro: https://github.com/dotnet/corefx/issues/42145

ahsonkhan avatar Nov 13 '19 01:11 ahsonkhan

image Please see the attachment for the project WorkerService1.zip

beefsteak avatar Nov 15 '19 04:11 beefsteak

Please see the attachment for the project

This isn't a valid project/solution (and the files contain gibberish, including the cs/json files - are they encrypted or transformed in some way). Please fix this before sharing. What encoding are you saying these files as?

image

ahsonkhan avatar Nov 15 '19 21:11 ahsonkhan

@ahsonkhan Sorry,I forgot that our project has been encrypted, so we can't transfer the project and I checked that the file format was utf-8

beefsteak avatar Nov 16 '19 12:11 beefsteak

If you can't attach your full project, can you attach just the json file?

scalablecory avatar Nov 21 '19 21:11 scalablecory

@scalablecory Hello, I think I have found the problem, it should be my machine installed the encryption firewall problem, it caused the json file to be encrypted, but I haven't found out why only debugging this problem, but thank you for your patience to solve, I think this problem can be closed.

beefsteak avatar Dec 01 '19 04:12 beefsteak

Hello, have you encountered this problem because you put a password on your own computer ?

nyf16 avatar Feb 14 '20 08:02 nyf16

@scalablecory Hello, I think I have found the problem, it should be my machine installed the encryption firewall problem, it caused the json file to be encrypted, but I haven't found out why only debugging this problem, but thank you for your patience to solve, I think this problem can be closed.

Hi, I am getting the same problem in my machine. Could you please help me the steps you followed to fix this problem. Thanks in advance

KrishnaManju avatar May 10 '20 03:05 KrishnaManju