Aam*_*mir 0 c# asp.net asp.net-core
如果整数属性为 0 忽略它,来自 json 对象。
[JsonProperty("amount")]
public int Amount { get; set; }
Run Code Online (Sandbox Code Playgroud)
我不想在应用程序中全局应用它。
小智 5
这可以使用Json-Ignore 属性来实现。
代码将是:
[JsonProperty("amount")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int Amount { get; set; }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123 次 |
| 最近记录: |