这两件json有什么区别

时间:2017-03-30 23:23:26

标签: json wcf

在我们重写系统以使用wcf服务之前,返回客户端的json是:

{"CreationDate":"2016-12-01T13:15:02.923+00:00","Email":"sagysad@dd.com","IsApproved":true,"IsLockedOut":false,"IsOnline":true,"LastActivityDate":"2017-03-31T00:13:21.333+01:00","LastLockoutDate":"1754-01-01T00:00:00+00:00","LastLoginDate":"2017-03-31T00:13:21.113+01:00","LastPasswordChangedDate":"2099-12-31T00:00:00+00:00","ProviderName":"LoginProvider","ProviderUserKey":"dcc5f38f-f71e-4d9d-bdb2-58fb60b7a65e","UserName":"schoi","IsValidLogin":true}

但是在将它作为wcf服务公开之后,json已经改为:

{
    "SignInResult":
    {
        "CreationDate": "/Date(1480598102923+0000)/",
        "Email": "steven.choi@dasdada.com",
        "IsApproved": true,
        "IsLockedOut": false,
        "IsOnline": true,
        "IsValidLogin": true,
        "LastActivityDate": "/Date(1490916050417+0100)/",
        "LastLockoutDate": "/Date(-6816268800000+0000)/",
        "LastLoginDate": "/Date(1490916050417+0100)/",
        "LastPasswordChangedDate": "/Date(-2208988800000+0000)/",
        "ProviderName": "LoginProvider",
        "ProviderUserKey": "dcc5f38f-f71e-4d9d-bdb2-58fb60b7a65e",
        "UserName": "schoi"
    }
}

为什么我不能这样做

JsonConvert.DeserializeObject<SignInResult>((provider.SignIn(username,password))

1 个答案:

答案 0 :(得分:1)

根据此msdn linkDateTime个对象是:

  

...在JSON中表示为“/ Date(刻度数)/”。的数量   ticks是指示数字的正或负长值   自1月1日午夜起经过的蜱(毫秒),   1970 UTC。

如果你想用新闻软件来保存它,你可以使用它:

        JsonSerializerSettings settings = new JsonSerializerSettings
        {
            DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
            Formatting = Formatting.Indented
        };
JsonConvert.DeserializeObject<SignInResult>((provider.SignIn(username,password), settings )