fix(#I12XVH): 使用 System.Text.Json 反序列化手机消息返回值
#Comment comment #I12XVH 设置忽略大小写 PropertyNameCaseInsensitive = true #Issue link #I12XVH
This commit is contained in:
parent
f444db2ad6
commit
cde6f0321e
|
@ -44,12 +44,7 @@ namespace Bootstrap.DataAccess
|
|||
var req = await client.GetAsync(url);
|
||||
var content = await req.Content.ReadAsStringAsync();
|
||||
#if NETCOREAPP3_0
|
||||
// UNDONE: 此处反序列化失败原因不明
|
||||
// var result = JsonSerializer.Deserialize<SMSResult>(content);
|
||||
var result = new SMSResult();
|
||||
var doc = JsonDocument.Parse(content);
|
||||
result.Code = doc.RootElement.GetProperty("code").GetInt32();
|
||||
result.Data = doc.RootElement.GetProperty("data").GetString();
|
||||
var result = JsonSerializer.Deserialize<SMSResult>(content, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });
|
||||
#else
|
||||
var result = JsonConvert.DeserializeObject<SMSResult>(content, new JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue