fixed toJSON and fromJSON