fix(#I12XVH): 使用 System.Text.Json 反序列化手机消息返回值

#Comment
comment #I12XVH
设置忽略大小写 PropertyNameCaseInsensitive = true

#Issue
link #I12XVH
This commit is contained in:
Argo Zhang 2019-10-04 10:30:57 +08:00
parent f444db2ad6
commit cde6f0321e
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 1 additions and 6 deletions

View File

@ -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