How to parse ASP.NET JSON Date format with GWT

后端 未结 2 1608
面向向阳花
面向向阳花 2021-01-19 04:14

ASP.NET JSON serialize DateTime to the following format \"/Date(1251877601000)/\". Pls, help parse this string into the java(GWT) Date object.

At this time the solut

2条回答
  •  遇见更好的自我
    2021-01-19 04:53

    The answer to this question is, use nuget to obtain JSON.NET then use this inside your JsonResult method:

    return Json(JsonConvert.SerializeObject(/* JSON OBJECT TO SEND TO VIEW */));
    

    inside your view simple do this in javascript:

    JSON.parse(@Html.Raw(Model.data))
    

    If it comes via a view model that is or if it is an ajax call:

    var request = $.ajax({ url: "@Url.Action("SomeAjaxAction", "SomeController")", dataType: "json"});
    request.done(function (data, result) { JSON.parse(data); });
    

提交回复
热议问题