jquery.observable icon indicating copy to clipboard operation
jquery.observable copied to clipboard

implement `.toJSON` to support `JSON.stringify`

Open Raynos opened this issue 13 years ago • 1 comments

If you implement a .toJSON method on your observable object then it will work with JSON.stringify.

In case you don't know, JSON.stringify will call a .toJSON method if it exists on the object you pass in and then stringify the return value.

Example:

var o = $.observable(someData);
// your toJSON method called $.observable.remove(o) for me.
JSON.stringify(o);

Raynos avatar Oct 29 '11 21:10 Raynos

Thanks, I will implement that for sure

erosb avatar Oct 30 '11 11:10 erosb