【发布时间】:2019-02-27 12:59:39
【问题描述】:
我有以下字典:
[JsonProperty("Simulations")]
public IDictionary<int, Simulation> Simulations { get; set; }
实际行为:
当我将数据发送到前端时,我将其作为对象发送:
"simulations": {
"02": {
"rachatBrut": 542,
"montantPercu": 250,
},
"52": {
"rachatBrut": 400,
"montantPercu": 385,
},
}
想要的行为
我只想将字典的值作为数组发送:
"simulations": [
{
"rachatBrut": 542,
"montantPercu": 250,
},
{
"rachatBrut": 400,
"montantPercu": 385,
}
]
【问题讨论】:
-
JsonIgnore现有属性。创建一个新的只读属性,该属性在 JSON 中投影您想要的数组。
标签: c# json asp.net-core deserialization