用Guid反序列化类不会解析guid值

时间:2018-09-11 00:42:20

标签: c# json.net json-deserialization

我正在从HttpClient获取请求获取json。结果是反序列化除Guid和Datetime之外的所有属性。 Guid属性将解析为 {System.Guid} ,日期将解析为 {System.DateTime}

网络请求:

var json = await response.Content.ReadAsStringAsync();

var result = JsonConvert.DeserializeObject<ICollection<UserEntity>>(json);

Json:

[{"Id":"5aee0750-6cd9-4d20-9fe9-1f7e23a4520b","MemberShipUserID":12346,
"Username":"Joshr","EmpName":"Josh","Password":"test123",
"Email":"nanidotnetdev@gmail.com","Phone":"1234567899",
"IsActive":true,"IsContractor":true,"RoleID":null,"ProfilePhotoID":null,
"CreatedDate":"2018-08-08T01:15:12.73",
"CreatedBy":"e4c6d172-3d14-4539-9fee-306b081dc3db","UpdatedDate":null,
"UpdatedBy":null,"LastLoginDate":null}]

UserEntity:

public class UserEntity
    {
        public Guid Id { get; set; }

        public int? MemberShipUserID { get; set; }

        public string Username { get; set; }

        public string EmpName { get; set; }

        public string Password { get; set; }

        public string Email { get; set; }

        public string Phone { get; set; }

        public bool IsActive { get; set; }

        public bool IsContractor { get; set; }

        public Guid? RoleID { get; set; }

        public string ProfilePhotoID { get; set; }

        public DateTime CreatedDate { get; set; }

        public Guid CreatedBy { get; set; }

        public DateTime? UpdatedDate { get; set; }

        public Guid? UpdatedBy { get; set; }

        public DateTime? LastLoginDate { get; set; }
    }

我在这里错过任何财产声明吗?请澄清。

谢谢

0 个答案:

没有答案