code: def to_json(
      df,
      url_path,
      orient="records",
      lines=None,
      storage_options=None,
      compute=True,
      encoding="utf-8",
      errors="strict",
      compression=None,
      compute_kwargs=None,
      name_function=None,
      **kwargs,
  ):
      """Write dataframe into JSON text files
  
      This utilises ``pandas.DataFrame.to_json()``, and most parameters are
      passed through - see its docstring.
  
      Differences: orient is 'records' by default, with lines=True; this
      produces the kind of JSON output that is most common in big-data
      applications, and which can be chunked when reading (see ``read_json()``).
  
      Parameters
      ----------
      df: dask.DataFrame
          Data to save
      url_path: str, list of str
          Location to write to. If a string, and there are more than one
          partitions in df, should include a glob character to expand into a
          set of file names, or provide a ``name_function=`` parameter.
          Supports protocol specifications such as ``"s3://"``.
      encoding, errors:
          The text encoding to implement, e.g., "utf-8" and how to respond
          to errors in the conversion (see ``str.encode()``).
      orient, lines, kwargs
          passed to pandas; if not specified, lines=True when orient='records',
          False otherwise.
      storage_options: dict
          Passed to backend file-system implementation
      compute: bool
          If true, immediately executes. If False, returns a set of delayed
          objects, which can be computed at a later time.
      compute_kwargs : dict, optional
          Options to be passed in to the compute method
      compression : string or None
          String like 'gzip' or 'xz'.
      name_function : callable, default None
          Function accepting an integer (partition index) and producing a
          string to replace the asterisk in the given filename globstring.
          Should preserve the lexicographic order of partitions.
      """
      if lines is None:
          lines = orient == "records"
      if orient != "records" and lines:
          raise ValueError(
              "Line-delimited JSON is only available with"
              'orient="records".'
          )
      kwargs["orient"] = orient
      kwargs["lines"] = lines and orient == "records"
      outfiles = open_files(
          url_path,
          "wt",
          encoding=encoding,
          errors=errors,
          name_function=name_function,
          num=df.npartitions,
          compression=compression,
          **(storage_options or {}),
      )
      parts = [
          delayed(write_json_partition)(d, outfile, kwargs)
          for outfile, d in zip(outfiles, df.to_delayed())
      ]
      if compute:
          if compute_kwargs is None:
              compute_kwargs = dict()
          return list(dask_compute(*parts, **compute_kwargs))
      else:
          return parts
  
imports: from __future__ import annotations
  import io
  import os
  from functools import partial
  from itertools import zip_longest
  import pandas
  from fsspec.core import open_files
  from dask.base import compute
  from dask.bytes import read_bytes
  from dask.core import flatten
  from dask.dataframe._compat import PANDAS_GE_200, PANDAS_VERSION
  from dask.dataframe.backends import dataframe_creation_dispatch
  from dask.dataframe.io.io import from_delayed
  from dask.dataframe.utils import insert_meta_param_description, make_meta
  from dask.delayed import delayed
label_desc: Use image node_id 1 for calling a global function with example usage: to_json(df, url_path, orient, lines, storage_options, compute, encoding, errors, compression, compute_kwargs, name_function) and returns: list, parts