Answer the question
In order to leave comments, you need to log in
Serializing an object with Date in unix format - how to do it?
Good afternoon!
I must say right away that the question is about Action Script. In the same C#, everything is done with a bang without a tambourine.
There is a Flash client (ActionScript, no Flex) and an ASP.NET server. Data in JSON is chasing between them. The model of the object is the simplest, but it is in it that there is a plug:
class Simple
{
public var Name:String;
public var Number: String;
public var RegistrationDate: Date;
}
Date.prototype.toJSON = function (k):*
{
return "\/Date(" + this.getTime() + ")\/"; // ЧТО ТУТ????
}
Answer the question
In order to leave comments, you need to log in
See https : //developer.mozilla.org/en-US/docs/Web/JavaS... , https://msdn.microsoft.com/library/cc836459(v=vs.94).aspx
function replacer(key, value) {
if (typeof value === "string") {
return undefined;
}
return value;
}
var foo = {foundation: "Mozilla", model: "box", week: 45, transport: "car", month: 7};
var jsonString = JSON.stringify(foo, replacer);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question