Is there a way to parse a JSON string into an existing Javascript object: Lets say i have created this object:
var ClientState = function(){
this.userId ="";
this.telephoneState = "UNKNOWN";
this.agentState = "UNKNOWN";
this.muteState = "UNKNOWN";
this.number = "";
this.ready = false;
}
ClientState.prototype = {
doNastyStuff: function(){
//do something here
}
//other methods here
}
I have this json coming through the wire:
{"userId":"xyz","telephoneState":"READY","agentState":"UNKNOWN","muteState":"MUTED","number":"","ready":false}
Is it possible to deserialize into the object specified above? So that i can use all methods specified on it? Or in general is it possible to deserialize into a specific target object (without specifying deserialization in this target object)? (I know that i could create an constructor that accepts json or a parsed object.)