以下代码不会使用false
在true
属性上映射JsonConvert.PopulateObject
。其他属性工作正常。我在做错什么吗?
JsonConvert.PopulateObject(json, request);
JSON
{ "EventId": 146282, "Name": "api division 9", "Order": 4, "Description": "test", "Active": false }
Account.cs
[DataContract(Name = "Request", Namespace = "")]
public class ApiCreateDivisionRequest : ApiAuthorizedRequest
{
[DataMember(IsRequired = false, EmitDefaultValue = false)]
public bool Active { get; set; }
答案 0 :(得分:1)
EmitDefaultValue
必须为true