I have a JSON string like this one: (data is faked, my company is very restrictive...)
{
"people" : {
"101" : {
"name" : "Strub, Thomas Reto",
"birthdate" : "/Date(690595200000)/"
}
},
"generated" : "/Date(1340755200000)/"
}
and I use this reviver when parsing:
var jsonMSDateTime = new RegExp('^\\/Date\\([0-9]{13}\\)\\/$');
function jsonReviver(key, value) {
if (jsonMSDateTime.test(value)) return new Date(value.substr(6, 13) * 1);
else return value;
}
My Problem is the following: If I run this script in IE, the generated date is parsed, but the birthdate is not. (It works in chrome, however.)
What mistake did I make?
console.log('Reviving ' + key + ' ' + value);
to the beginning of the function to see if the birthdate is ever passed to the reviver.0
and the valueundefined
is processed. Do I have to return a different value instead? (The item is not removed, asundefined
should cause, instead it's just not processed. If I change the peoples-object to an array ("people" : [{ ... }]
), everything works fine.undefined
instead of the person.