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
new JSONApiDeserializer(
typeForAttribute: function(attribute) {
if (typeof attribute === 'string') {
const match = attribute.match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ$/);
return match ? new Date(attribute) : undefined;
}
return undefined;
}
).deserialize(data);
But the I found out that the deserializer doesn't take this configuration option (compared to the serializer who does). Is there a specific reason for that?
My current workaround looks like this:
function couldBeDate(dateString) {
return !!dateString.match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ$/);
}
function deserializeDatesInplace(obj) {
Reflect.ownKeys(obj).forEach(key => {
if (typeof obj[key] === 'object') {
deserializeDatesInplace(obj[key])
}
if (typeof obj[key] === 'string' && couldBeDate(obj[key])) {
obj[key] = new Date(obj[key])
}
});
}
The text was updated successfully, but these errors were encountered:
I just wanted to try the following:
But the I found out that the deserializer doesn't take this configuration option (compared to the serializer who does). Is there a specific reason for that?
My current workaround looks like this:
The text was updated successfully, but these errors were encountered: