Fixed toJSON method signature.