Skip to content

Commit

Permalink
F-尝试解决解析失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
leaf1170124460 committed Jun 2, 2020
1 parent a9e0d17 commit 0ba06d9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions CodeChatSDK/Utils/ChatMessageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,24 @@ public static void ParseContent(ChatMessage message)
//判断是否为普通文本消息
if (message.IsPlainText == true)
{
//解析内容为聊天消息
message.Text = JsonConvert.DeserializeObject<string>(message.Content);
try
{
//解析内容为聊天消息
message.Text = JsonConvert.DeserializeObject<string>(message.Content);
}
catch
{
//解析内容为聊天消息
var chatMessage = JsonConvert.DeserializeObject<ChatMessage>(message.Content
, new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
});
message.Ent = chatMessage.Ent;
message.Fmt = chatMessage.Fmt;
message.Text = chatMessage.Text;
}

}
else
{
Expand Down

0 comments on commit 0ba06d9

Please sign in to comment.