mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
fix(work): 尝试规避部分场景下企业会话存档 JSON 反序列化异常的问题
This commit is contained in:
parent
7662f8dc9a
commit
0d6604c61a
@ -227,7 +227,28 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.SDK.Finance
|
||||
throw new PlatformNotSupportedException();
|
||||
string dataContent = MarshalerHelper.PtrToStringUTF8(dataContentPtr);
|
||||
|
||||
response = JsonSerializer.Deserialize<Models.DecryptChatRecordResponse>(dataContent);
|
||||
try
|
||||
{
|
||||
response = JsonSerializer.Deserialize<Models.DecryptChatRecordResponse>(dataContent);
|
||||
}
|
||||
catch (System.Text.Json.JsonException)
|
||||
{
|
||||
// NOTICE: 某些情况下微信返回的 JSON 字符串中包含设备控制符,可能导致 System.Text.Json 反序列化抛出异常
|
||||
if (JsonSerializer is FlurlSystemTextJsonSerializer)
|
||||
{
|
||||
string fixedDataContent = dataContent
|
||||
.Replace("\\u0011", string.Empty)
|
||||
.Replace("\\u0012", string.Empty)
|
||||
.Replace("\\u0013", string.Empty)
|
||||
.Replace("\\u0014", string.Empty);
|
||||
response = JsonSerializer.Deserialize<Models.DecryptChatRecordResponse>(fixedDataContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
response.RawBytes = Encoding.UTF8.GetBytes(dataContent);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user