抱歉,如果已经有人问过这个问题,假设我有一个匿名对象列表,如下所示:
Collection = new List<object>() {
new {
FirstSetting = new
{
FirstKEy = "Property vs Inspections",
color = "#FF6384",
fontStyle = "Arial",
sidePadding = 10,
}
},
new {
AnotherSettings = new
{
text = "another text",
color = "#FF6384",
fontStyle = "Arial",
sidePadding = 10,
}
}
};
并希望使用转换为JSON字符串
JsonConvert.SerializeObject(Collection, JsonSerializerSettings);
我得到这个结果。
[{
"FirstSetting": {
"FirstKey": "Property vs Inspections",
"color": "#FF6384",
"fontStyle": "Arial",
"sidePadding": 10
}
}, {
"anotherSettings": {
"text": "another text",
"color": "#FF6384",
"fontStyle": "Arial",
"sidePadding": 10
}
}]
但我不希望有一个数组。我想让每个设置都是这样的对象。
{
"FirstSetting": {
"FirstKey": "Property vs Inspections",
"color": "#FF6384",
"fontStyle": "Arial",
"sidePadding": 10
},
"anotherSettings": {
"text": "another text",
"color": "#FF6384",
"fontStyle": "Arial",
"sidePadding": 10
}
}
有人可以请问一下吗?
梵蒂冈之花
波斯汪
素胚勾勒不出你
相关分类