I have an invalid Json string that I need to parse to an object and feed to a viewmodel:
var s = "{ a: new Date(1400000000000) }"; // from a server, can't change this
eval("var b = " + s); // parse it to a var b
var vm = new viewmodel(b); // pass var b to the viewmodel
This works, but I end up with an intermediate object b before I can use the parsed object
So I tried:
var s = "{ a: new Date(1400000000000) }"; // from a server, can't change this
var vm = new viewmodel(eval(s)); // parse the object and pass to viewmodel
but that doesn't work
Can you explain why?
Is there another way to do this without the need for an intermediate var b?