def maybe_to_json(self, obj: Any):
        """Call `cirq.to_json with `value` according to the configuration options in this class.

        If `checkpoint=False`, nothing will happen. Otherwise, we will use `checkpoint_fn` and
        `checkpoint_other_fn` as the destination JSON file as described in the class docstring.
        """
        if not self.checkpoint:
            return
        assert self.checkpoint_fn is not None, 'mypy'
        assert self.checkpoint_other_fn is not None, 'mypy'
        if os.path.exists(self.checkpoint_fn):
            os.replace(self.checkpoint_fn, self.checkpoint_other_fn)
        protocols.to_json(obj, self.checkpoint_fn)
Call `cirq.to_json with `value` according to the configuration options in this class.

        If `checkpoint=False`, nothing will happen. Otherwise, we will use `checkpoint_fn` and
        `checkpoint_other_fn` as the destination JSON file as described in the class docstring.
        
cirq-core/cirq/work/observable_measurement.py