【发布时间】:2019-02-25 20:22:30
【问题描述】:
我正在尝试序列化我认为是 .NET Core 2.2 应用程序中不寻常的 JSON 结构。
{
"id": "002a40a1-2e31-4663-a8d0-a4e6e2742d62",
"data": [
1,
[
"value",
false
]
]
}
当我尝试在 c# 中对数据属性建模时,我感到困惑
public class DataItem {
[JsonProperty("id")]
string id;
[JsonProperty("data")]
public object[] data;
}
我不知道如何在 C# 中正确建模此结构以允许 Newtonsoft 对其进行反序列化。
【问题讨论】:
-
使用属性而不是字段
标签: c# json .net-core json.net