code: def json(self, with_candidates=False):
          
  
          def _json_or_none(obj):
              return None if obj is None else obj.json()
  
          data = {
              "status": self.status,
              "method_name": self.method_name,
              "interval": self.interval,
              "model": _json_or_none(self.model),
              "r_squared_adj": _noneify(self.r_squared_adj),
              "warnings": [w.json() for w in self.warnings],
              "metadata": self.metadata,
              "settings": self.settings,
              "totals_metrics": _json_or_none(self.totals_metrics),
              "avgs_metrics": _json_or_none(self.avgs_metrics),
              "candidates": None,
          }
          if with_candidates:
              data["candidates"] = [candidate.json() for candidate in self.candidates]
          return data
docs: Return a JSON-serializable representation of this result.
  
          The output of this function can be converted to a serialized string
          with :any:`json.dumps`.