You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to use this library to serialise a Date value to an ISO-8601 string?
for example, I want this:
classMyObject{
@serializable/* Need to specify the target here?*/MyDate!: Date}constmyObject=newMyObject();myObject.MyDate=newDate();constjson=serialize(myObject);console.log(json);
To output this:
'{"MyDate":"2021-07-27T14:39:15.915Z"}'
And then I want to be able to do the reverse of this; deserialze this JSON into an instance of MyObject, with MyDate properly instantiated.
Is it possible to use this library to serialise a
Date
value to anISO-8601
string?for example, I want this:
To output this:
And then I want to be able to do the reverse of this; deserialze this JSON into an instance of
MyObject
, withMyDate
properly instantiated.should output this:
I've tried declaring the
@serializable
attribute withdate()
in the constructor, which outputs the date as epoch as per the docs.I've tried declaring the
@serializable
attribute usingprimitive()
in the constructor, which I think should be valid based on this:But this throws the error:
Any help with this would be appreciated.
The text was updated successfully, but these errors were encountered: