added toJSON/fromJSON