Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个使用 NewtonSoft 的 JSON 序列化程序的简单方法,我喜欢它(简单,返回格式化的 JSON)。但是,我似乎无法让它正确序列化对象内的字符串中的 UTF8 字符(它们显示为问号,即“?”)。
我正在使用的代码是:
string serialized = JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { });
由于您要序列化为字符串而不是字节数组,因此在此阶段您无需处理任何字符编码(如 utf-8)。
您必须找出它在哪里实际转换为/从 UTF-8 转换并在那里解决问题。