小编Lav*_*iel的帖子

Facebook json 消息的编码/解码问题。C# 解析

我已经下载了 json 和我的对话存档。我坚持使用奇怪的编码。

\n\n

json 示例:

\n\n
{\n  "sender_name": "Micha\\u00c5\\u0082",\n  "timestamp": 1411741499,\n  "content": "b\\u00c4\\u0099d\\u00c4\\u0099",\n  "type": "Generic"\n},\n
Run Code Online (Sandbox Code Playgroud)\n\n

它应该是这样的:

\n\n
{\n  "sender_name": "Micha\xc5\x82",\n  "timestamp": 1411741499,\n  "content": "b\xc4\x99d\xc4\x99",\n  "type": "Generic"\n},\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在尝试像这样反序列化它:

\n\n
var result = File.ReadAllText(jsonPath, encodingIn);\nJavaScriptSerializer serializer = new JavaScriptSerializer();\nserializer.MaxJsonLength = Int32.MaxValue;\nvar conversation = serializer.Deserialize<Conversation>(System.Net.WebUtility.HtmlDecode(result));\n
Run Code Online (Sandbox Code Playgroud)\n\n

不幸的是输出是这样的:

\n\n
{\n  "sender_name": "Micha\xc3\x85\\u0082",\n  "timestamp": 1411741499,\n  "content": "b\xc3\x84\\u0099d\xc3\x84\\u0099",\n  "type": "Generic"\n},\n
Run Code Online (Sandbox Code Playgroud)\n\n

有人知道 Facebook 如何编码 json 吗?我尝试了多种方法但没有结果。

\n\n

感谢您的帮助。

\n

c# encoding json facebook

4
推荐指数
1
解决办法
1803
查看次数

标签 统计

c# ×1

encoding ×1

facebook ×1

json ×1