code: def add_to_json(
      file_path,
      data_to_add,
      key=None,
      condition=None,
      default=None,
      append_value=False,
  ):
      """Append `data_to_add` to the contents of the .json file specified by `file_path`
  
      Parameters
      ----------
      file_path: String
          The target .json file path to which `data_to_add` will be added and saved
      data_to_add: Object
          The data to add to the contents of the .json file given by `file_path`
      key: String, or None, default=None
          If None, the original contents of the file at `file_path` should not be of type dict. If
          string, the original content at `file_path` is expected to be a dict, and `data_to_add` will
          be added to the original dict under the key `key`. Therefore, `key` is expected to be a
          unique key to the original dict contents of `file_path`, unless `append_value` is True
      condition: Callable, or None, default=None
          If callable, will be given the original contents of the .json file at `file_path` as input,
          and should return a boolean value. If `condition(original_data)` is truthy, `data_to_add`
          will be added to the contents of the file at `file_path` as usual. Otherwise, `data_to_add`
          will not be added to the file, and the contents at `file_path` will remain unchanged. If
          `condition` is None, it will be treated as having been truthy, and will proceed to append
          `data_to_add` to the target file
      default: Object, or None, default=None
          If the attempt to read the original content at `file_path` raises a `FileNotFoundError` and
          `default` is not None, `default` will be used as the original data for the file. Otherwise,
          the error will be raised
      append_value: Boolean, default=False
          If True and the original data at `file_path` is a dict, then `data_to_add` will be appended
          as a list to the value of the original data at key `key`"""
      try:
          original_data = read_json(file_path)
      except FileNotFoundError:
          if default is not None:
              original_data = default
          else:
              raise
  
      if (
          condition is None
          or original_data is None
          or condition(original_data)
      ):
          if key is None and isinstance(original_data, list):
              original_data.append(data_to_add)
          elif isinstance(key, str) and isinstance(original_data, dict):
              if append_value is True:
                  original_data[key] = original_data[key] + [
                      data_to_add
                  ]
              else:
                  original_data[key] = data_to_add
  
          write_json(file_path, original_data)
  
imports: from hyperparameter_hunter.settings import G
  from contextlib import suppress
  from inspect import signature
  import numpy
  import os
  import os.path
  import pandas
  import simplejson
  from typing import Union
  import wrapt
label_desc: Use image node_id 5 for calling a global function with example usage: add_to_json(file_path, data_to_add, key, condition, default, append_value) without return types