更新时间:2023-11-28 23:12:58
是的.当您用[JsonObjectAttribute]
标记类并传递MemberSerialization.OptIn
参数时,成员序列化选择加入.然后用[JsonProperty]
标记您的成员以包括它们以进行序列化.
Yes there is. When you mark your class with [JsonObjectAttribute]
and pass the MemberSerialization.OptIn
parameter, member serialization is opt-in. Then mark your members with [JsonProperty]
to include them for serialization.
[JsonObject(MemberSerialization.OptIn)]
public class Person
{
[JsonProperty]
public string Name { get; set; }
// not serialized because mode is opt-in
public string Department { get; set; }
}