I would like to serialize/stringify a javascript object that can be passed between browsers as a string using signalr
The signalr portion is working, as i can send and receive chat messages.
This is my simple test rig
function UserObject() {
var _firstName = 't';
this.getFirstName = function () {
return _firstName;
}
this.setFirstName = function (value) {
_firstName = value;
}
}
var userObject = new UserObject();
console.log(userObject.getFirstName());
userObject.setFirstName('tony');
console.log(JSON.stringify(userObject));
console.log("First Name: " + userObject.getFirstName());
This is the results that i am receiving.
> "t"
> "{}"
> "First Name: tony"
Why is the console.log(JSON.stringify(userObject)) failing? When i can set the value, reset the value and not see the value when i try to view the object.