code: def write_json(
      data: Any,
      filepath: types.PathLike,
      *,
      mode: str = "wt",
      encoding: Optional[str] = None,
      make_dirs: bool = False,
      lines: bool = False,
      ensure_ascii: bool = False,
      separators: tuple[str, str] = (",", ":"),
      sort_keys: bool = False,
      indent: Optional[int | str] = None,
  ) -> None:
      """
      Write JSON ``data`` to disk at ``filepath``, either all at once
      or streaming item-by-item.
  
      Args:
          data: JSON data to write to disk, including any Python objects
              encodable by default in :mod:`json`, as well as dates and datetimes.
              For example::
  
                  [
                      {"title": "Harrison Bergeron", "text": "The year was 2081, and everybody was finally equal."},
                      {"title": "2BR02B", "text": "Everything was perfectly swell."},
                      {"title": "Slaughterhouse-Five", "text": "All this happened, more or less."},
                  ]
  
              If ``lines`` is False, all of ``data`` is written as a single object;
              if True, each item is written to a separate line in ``filepath``.
  
          filepath: Path to file on disk to which data will be written.
          mode: Mode with which ``filepath`` is opened.
          encoding: Name of the encoding used to decode or encode the data
              in ``filepath``. Only applicable in text mode.
          make_dirs: If True, automatically create (sub)directories if
              not already present in order to write ``filepath``.
          lines: If False, all data is written at once;
              otherwise, data is written to disk one item at a time.
          ensure_ascii: If True, all non-ASCII characters are escaped;
              otherwise, non-ASCII characters are output as-is.
          separators: An (item_separator, key_separator) pair
              specifying how items and keys are separated in output.
          sort_keys: If True, each output dictionary is sorted by key;
              otherwise, dictionary ordering is taken as-is.
          indent: If a non-negative integer or string, items are pretty-printed
              with the specified indent level; if 0, negative, or "", items are separated
              by newlines; if None, the most compact representation is used
              when storing ``data``.
  
      See Also:
          https://docs.python.org/3/library/json.html#json.dump
      """
      io_utils._validate_write_mode(mode)
      with io_utils.open_sesame(
          filepath, mode=mode, encoding=encoding, make_dirs=make_dirs
      ) as f:
          if lines is False:
              f.write(
                  json.dumps(
                      data,
                      indent=indent,
                      ensure_ascii=ensure_ascii,
                      separators=separators,
                      sort_keys=sort_keys,
                      cls=ExtendedJSONEncoder,
                  )
              )
          else:
              newline: Union[str, bytes] = (
                  "\n" if "t" in mode else b"\n"
              )
              for item in data:
                  f.write(
                      json.dumps(
                          item,
                          indent=indent,
                          ensure_ascii=ensure_ascii,
                          separators=separators,
                          sort_keys=sort_keys,
                          cls=ExtendedJSONEncoder,
                      )
                      + newline
                  )
  
file_path: textacy/src/textacy/io/json.py
imports: from __future__ import annotations
  import datetime
  import functools
  import json
  from typing import Any, Iterable, Optional, Union
  from ..None import types
  from .None import utils
label_desc: Use image node_id 3 for calling a global function with example usage: write_json(data, filepath) without return types