code: def get_stopped_experiment_config_json(
      exp_id: str, exp_dir: str | None = None
  ) -> dict | None:
      """Get the experiment config, in JSON format, of a stopped experiment.
  
      Different from :func:`get_stopped_experiment_config`,
      this function does not load the config into an :class:`ExperimentConfig` object.
      It doesn't check the experiment directory contained inside the config JSON either.
  
      NOTE: The config is retrieved from SQL database, and should be written by NNI manager in current implementation.
  
      Parameters
      ----------
      exp_id
          The experiment ID.
      exp_dir
          The experiment working directory which is expected to contain a folder named ``exp_id``.
          If ``exp_dir`` is not provided, the directory will be retrieved from the manifest of all experiments.
  
      Returns
      -------
      The config JSON.
      """
      if exp_dir:
          return Config(exp_id, exp_dir).get_config()
      else:
          update_experiment()
          experiments_config = Experiments()
          experiments_dict = experiments_config.get_all_experiments()
          experiment_metadata = experiments_dict.get(exp_id)
          if experiment_metadata is None:
              _logger.error("Id %s not exist!", exp_id)
              return None
          if experiment_metadata["status"] != "STOPPED":
              _logger.error(
                  "Only stopped experiments can be resumed or viewed! But retrieved metadata for %s is:\n%s",
                  exp_id,
                  experiment_metadata,
              )
              return None
          return Config(
              exp_id, experiment_metadata["logDir"]
          ).get_config()
  
imports: from __future__ import annotations
  import contextlib
  from dataclasses import dataclass, fields
  from datetime import datetime
  import logging
  import os.path
  from pathlib import Path
  import socket
  from subprocess import Popen
  import sys
  import time
  from typing import Any, TYPE_CHECKING, cast
  from typing_extensions import Literal
  from .config import ExperimentConfig
  from .None import rest
  from ..tools.nnictl.config_utils import Experiments, Config
  from ..tools.nnictl.nnictl_utils import update_experiment
label_desc: Use image node_id 7 for calling a global function with example usage: get_stopped_experiment_config_json(exp_id, exp_dir) and returns: Config, Config, None, None