code: def test_metrics_show_json(dvc, mocker, capsys):
      cli_args = parse_args(
          [
              "metrics",
              "show",
              "--json",
              "--all-tags",
              "--all-branches",
              "--all-commits",
              "target1",
              "target2",
              "--precision",
              "8",
          ]
      )
  
      assert cli_args.func == CmdMetricsShow
      cmd = cli_args.func(cli_args)
      d = {
          "branch_1": {
              "metrics.json": {"b": {"ad": 1, "bc": 2}, "c": 4}
          },
          "branch_2": {
              "metrics.json": {"a": 1, "b": {"ad": 3, "bc": 4}}
          },
      }
      metrics_show = mocker.patch(
          "dvc.repo.metrics.show.show", return_value=d
      )
      show_metrics_mock = mocker.patch("dvc.compare.show_metrics")
  
      assert cmd.run() == 0
      out, _ = capsys.readouterr()
      metrics_show.assert_called_once_with(
          cmd.repo,
          ["target1", "target2"],
          all_tags=True,
          all_branches=True,
          all_commits=True,
      )
      show_metrics_mock.assert_not_called()
      assert json.dumps(d) in out
  
imports: import json
  from dvc.cli import parse_args
  from dvc.commands.metrics import CmdMetricsDiff, CmdMetricsShow
label_desc: Use image node_id 4 for calling a global function with example usage: test_metrics_show_json(dvc, mocker, capsys) without return types