ak.to_json
----------

Defined in `awkward.operations.convert <https://github.com/scikit-hep/awkward-1.0/blob/80bbef0738a6b7928333d7c705ee1b359991de5b/src/awkward/operations/convert.py>`__ on `line 1142 <https://github.com/scikit-hep/awkward-1.0/blob/80bbef0738a6b7928333d7c705ee1b359991de5b/src/awkward/operations/convert.py#L1142>`__.

.. py:function:: ak.to_json(array, destination=None, pretty=False, maxdecimals=None, nan_string=None, infinity_string=None, minus_infinity_string=None, complex_record_fields=None, buffersize=65536)


    :param array: Data to convert to JSON.
    :param destination: If None, this function returns a JSON str;
                    if a str, it uses that as a file name and writes (overwrites) that
                    file (returning None).
    :type destination: None or str
    :param pretty: If True, indent the output for human readability; if
               False, output compact JSON without spaces.
    :type pretty: bool
    :param maxdecimals: If an int, limit the number of
                    floating-point decimals to this number; if None, write all digits.
    :type maxdecimals: None or int
    :param nan_string: If not None, floating-point NaN values will be
                   replaced with this string instead of a JSON number.
    :type nan_string: None or str
    :param infinity_string: If not None, floating-point positive infinity
                        values will be replaced with this string instead of a JSON number.
    :type infinity_string: None or str
    :param minus_infinity_string: If not None, floating-point negative
                              infinity values will be replaced with this string instead of a JSON
                              number.
    :type minus_infinity_string: None or str
    :param complex_record_fields: If not None, defines a pair of
                              field names to interpret records as complex numbers.
    :type complex_record_fields: None or (str, str)
    :param buffersize: Size (in bytes) of the buffer used by the JSON
                   parser.
    :type buffersize: int

Converts ``array`` (many types supported, including all Awkward Arrays and
Records) into a JSON string or file.

Awkward Array types have the following JSON translations.

   * :py:obj:`ak.types.PrimitiveType`: converted into JSON booleans and numbers.
   * :py:obj:`ak.types.OptionType`: missing values are converted into None.
   * :py:obj:`ak.types.ListType`: converted into JSON lists.
   * :py:obj:`ak.types.RegularType`: also converted into JSON lists. JSON (and
     Python) forms lose information about the regularity of list lengths.
   * :py:obj:`ak.types.ListType` with parameter ``"__array__"`` equal to
     ``"__bytestring__"`` or ``"__string__"``: converted into JSON strings.
   * :py:obj:`ak.types.RecordArray` without field names: converted into JSON
     objects with numbers as strings for keys.
   * :py:obj:`ak.types.RecordArray` with field names: converted into JSON objects.
   * :py:obj:`ak.types.UnionArray`: JSON data are naturally heterogeneous.

See also :py:obj:`ak.from_json` and :py:obj:`ak.Array.tojson`.

