Fix localStorage issue in Android

`JSON.stringify(this)` did not work on Android 2.3.
It returns `undefined` and stores the string`"undefined"` in localStorage.

Calling the toJSON() function to explicitly provide data fixes this issue.