Every object should have toJSON and fromJSON methods so you can have a reliable way to store and retrieve objects.