.. include:: ../../toolkit-substitutions

.. oe:namespace:: OESpruce

..  _OESpruce_OEHeterogenMetadataToJson:

.. oe:function:: OEHeterogenMetadataToJson

   .. attention::

      |TWOLANGUAGE|

   .. oe:language:: c++ java csharp

      .. oe:api::

         std::string OEHeterogenMetadataToJson(const OEHeterogenMetadata& metadata,
                                               const bool prettyPrint = true)

   .. oe:language:: python

      .. oe:api:: python

         OEHeterogenMetadataToJson(metadata: OEHeterogenMetadata,
                                   prettyPrint: bool = True) -> str

   Serializes an :oe:cls:`OESpruce::OEHeterogenMetadata` object to a JSON-formatted string.
   The resulting JSON object contains the following fields:

   .. list-table::
      :header-rows: 1
      :widths: 20 15 65

      * - Field
        - Type
        - Description
      * - ``Title``
        - string
        - Human-readable title of the heterogen.
      * - ``Id``
        - string
        - Identifier for the heterogen (e.g. PDB ligand code).
      * - ``Smiles``
        - string
        - SMILES representation of the heterogen.
      * - ``Type``
        - string
        - Heterogen component type name, as returned by :oe:func:`OESpruce::OEGetHeterogenTypeName`.
      * - ``Tautomers``
        - array of strings
        - SMILES strings of known tautomeric forms of the heterogen.

   The `prettyPrint` argument controls formatting: when ``true`` (the default) the JSON is
   indented for readability; when ``false`` a compact single-line representation is produced.

.. seealso::

   * :oe:func:`OESpruce::OEHeterogenMetadataFromJson` function
   * :oe:cls:`OESpruce::OEHeterogenMetadata` class
   * :oe:func:`OESpruce::OEGetHeterogenTypeName` function
