“EF BB BF” at the beginning of JSON files created in Visual Studio

前端 未结 2 949
无人及你
无人及你 2021-01-04 08:03

I have a bunch of JSON files set as Embedded resource in one of my projects. I\'m using Newtonsoft.Json to parse these files:

2条回答
  •  星月不相逢
    2021-01-04 08:47

    Change the encoding of the file - when saving there is a little down arrow that lets you go to advanced saving options, including the encoding.

    What you are seeing is the BOM (Byte Order Mark) - it indicates this is a Unicode file (UTF-8 in this case, I believe).

    You can also just strip it, which should let it parse without issue.

    This is something that is best just dealt with once, when saving the file than repeatedly fixing in code.

提交回复
热议问题