gpt4 book ai didi

c# - 使用 Newtonsoft 简化对象的反序列化

转载 作者:太空宇宙 更新时间:2023-11-03 14:40:23 25 4
gpt4 key购买 nike

<分区>

我有如下所示的 JSON:

[
{
"id": 7,
"name": "Example 1",
"player_class": 2,
"player_class_name": "Class1",
"url": "/someurl",
"standard_ccp_signature_core": {
"as_of": "2019-07-04T16:46:23.760Z",
"format": 2,
"components": [ 742, 51779, 51790, 503, 52810, 52819, 381, 49164, 48886, 56223 ]
},
"wild_ccp_signature_core": null
}
]

生成的类如下所示:

public class Archetype 
{
public int id { get; set; }
public string name { get; set; }
public string player_class_name { get; set; }

[JsonProperty("standard_ccp_signature_core")]
public StandardCcpSignatureCore core_cards { get; set; }
}

public class StandardCcpSignatureCore
{
public List<int> components { get; set; }
}

我想稍微简化一下 Archetype 类,使其看起来像这样:

public class Archetype 
{
public int id { get; set; }
public string name { get; set; }
public int player_class { get; set; }
public string player_class_name { get; set; }

[JsonProperty("standard_ccp_signature_core")]
public List<int> components { get; set; }
}

使用 Newtonsoft 解串器是否可行?我很确定我必须在我的 Archetype 类的 components 属性上设置一个 JsonObject 属性,但我不确定如何告诉它该怎么做。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com