【发布时间】:2019-11-29 12:24:25
【问题描述】:
如何忽略序列化中的属性,但在 c# 中使用 json.net 进行反序列化。
例子:
public class Foo
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("contentType")]
public object ContentType { get; set; }
[JsonProperty("content")]
public object Content { get; set; }
[JsonIgnore]
public Relationship RelationshipContent { get; set; }
[JsonIgnore]
public Domains DomainContent { get; set; }
}
在上面的代码中,我需要根据 PartType 属性值的值将“内容”反序列化为属性“RelationshipContent”和“DomainContent”。
你能帮我在 C# 中使用 Newtonsoft.Json 吗?
【问题讨论】:
标签: c# asp.net-core json.net json-deserialization