docs: def save_json(histogram: Union[HistogramBase, HistogramCollection], path: Optional[str] = None, **kwargs) -> str:
      """Save histogram to JSON format.
  
      Parameters
      ----------
      histogram : Any histogram
      path : If set, also writes to the path.
  
      Returns
      -------
      json : The JSON representation of the histogram
      """
      # TODO: Implement multiple histograms in one file?
      data = histogram.to_dict()
  
      data["physt_version"] = CURRENT_VERSION
      if isinstance(histogram, HistogramBase):
          data["physt_compatible"] = COMPATIBLE_VERSION
      elif isinstance(histogram, HistogramCollection):
          data["physt_compatible"] = COLLECTION_COMPATIBLE_VERSION
      else:
          raise TypeError("Cannot save unknown type: {0}".format(type(histogram)))
  
      text = json.dumps(data, **kwargs)
      if path:
          with open(path, "w", encoding="utf-8") as f:
              f.write(text)
      return text