I have a JSON object on client side that I want to get back on server side.
To do so, I have a hidden in which I put the stringified version of my object.
$("#<%=hidden.ClientID%>").val(JSON.stringify(obj));
Then, on server side, I try to deserialize it with JavaScriptSerializer.
My Problem : the stringified object contains a date and I can't parse it with de JavaScriptSerializer.
What I have done : Modify the date format to make it fit with the .Net format :
function FormatDate(date) {
if (typeof (date.getTime) != "undefined") {
return '\\/Date(' + date.getTime() + ')\\/'
}
return date;
}
Which seems to give a good format, but, when I use JSON.stringify on the object with the well formatted dates, it adds an extra backslash, so the JavaScriptSerializer still can't get it.
Any idea on how I could get it in a valid format in the hidden?