关于 使用 Swifter.Json 遇到的问题点
cpp
public enum RWFieldAccess : byte
{
//
// 摘要:
// 表示此字段允许读写。
RW = 3,
//
// 摘要:
// 表示忽略此字段。
Ignore = 0,
//
// 摘要:
// 表示此字段只能读。
ReadOnly = 1,
//
// 摘要:
// 表示此字段只能写。
WriteOnly = 2
}
// 此字段的名称。
public virtual string? Name { get; set; }
//
// 摘要:
// 此字段的排序值。约小越靠前,默认值为最靠后。
public virtual int Order { get; set; } = 999;
//
// 摘要:
// 字段的可访问性。
public virtual RWFieldAccess Access { get; set; } = RWFieldAccess.RW;
在github上的Attributes 特性说明只简单了说了一下 [RWField] [RWFormat]
讲真 一开始还真没明白要怎么操作
Access 为设置序列化的权限 我这边使用了忽略指定的字段不格式化
RWFormat 是格式化 比如把枚举字段格式化json的时候显示的是数字
RWFormat("d")
这个可以自己测试一下 不能格式化的时候 他会抛出异常出来
[RWField(Order = 3), RWFormat("d")] //我代码中的是这样操作
在这里简单记录一下