c# - Json反序列化和解码
问题描述
我得到外部 json 数据并想反序列化到我的集合:
var responseString = await response.Content.ReadAsStringAsync();
var result = JsonParse.ParseArrayCamelCase<ReadOnlyCollection<SureMdmGroup>>(responseString, "Groups");
return result;
哪里ParseArrayCamelCase
是:
public static T ParseArrayCamelCase<T>(string txt, string arrayName)
{
JObject json = JObject.Parse(txt);
var items = json[arrayName].ToString();
JsonSerializerSettings serSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Formatting = Formatting.Indented,
StringEscapeHandling = StringEscapeHandling.EscapeHtml
};
return JsonConvert.DeserializeObject<T>(items, serSettings);
}
它有效,但如果一些字符串像
E&B Transport, LLC.
它应该转换为
E&B 运输有限责任公司。
我应该设置什么JsonSerializerSettings
来解码字符串?
解决方案
推荐阅读
- node.js - 如何在 Node Express 应用程序更改时设置 WebStorm 2018 以刷新 Chrome
- sql - 在 Access 中动态构建 SQL 字符串
- javascript - 在烧瓶 Web 应用程序中使用 highcharts 饼图绘制数据
- python - @classmethod 不更新python中的类实例属性
- android - Android ViewModel 和 startActivity
- javascript - 在 iframe 内单击
- bash - Bash:如何将别名命令与 watch 结合使用
- nativescript - 在 nativescript 中看不到 console.log() 中的值
- sql - 如何将 DEFINE 变量设置为等于 PL/SQL 中另一个已定义表的选择
- csv - Can't display CSV file in pyspark(ValueError: Some types cannot be determined by the first 100 rows, please try again with sampling)