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

.. oe:namespace:: OESpruce

.. _OESpruce_OEStructureMetadataToJson:

.. oe:function:: OEStructureMetadataToJson

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         std::string OEStructureMetadataToJson(const OEStructureMetadata& metadata,
                                               const bool prettyPrint = true)

   .. oe:language:: python

      .. oe:api:: python

         OEStructureMetadataToJson(metadata: OEStructureMetadata,
                                   prettyPrint: bool = True) -> str

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

   .. list-table::
      :header-rows: 1
      :widths: 25 15 60

      * - Field
        - Type
        - Description
      * - ``StructureID``
        - string
        - Identifier for the structure (e.g. PDB accession code).
      * - ``Author``
        - string
        - Name of the structure's depositing author.
      * - ``Keywords``
        - array of strings
        - Keywords describing the structure.
      * - ``RevisionDate``
        - string
        - Date of the most recent revision.
      * - ``Revision``
        - string
        - Revision version label.
      * - ``ExperimentDate``
        - string
        - Date the experiment was performed.
      * - ``ExperimentType``
        - string
        - Experiment method name, as returned by :oe:func:`OESpruce::OEGetExperimentTypeName`.
      * - ``IridiumData``
        - object
        - Nested object containing Iridium quality assessment data.
      * - ``SequenceMetadata``
        - array of objects
        - Array of sequence segment objects, each with the fields documented in :oe:func:`OESpruce::OESequenceMetadataToJson`.
      * - ``HeterogenMetadata``
        - array of objects
        - Array of heterogen objects, each with the fields documented in :oe:func:`OESpruce::OEHeterogenMetadataToJson`.

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

   .. admonition:: Code Example

      * :ref:`spruce_examples_make_design_units_using_metadata` example

.. seealso::

   * :oe:func:`OESpruce::OEStructureMetadataFromJson` function
   * :oe:func:`OESpruce::OESequenceMetadataToJson` function
   * :oe:func:`OESpruce::OEHeterogenMetadataToJson` function
   * :oe:cls:`OESpruce::OEStructureMetadata` class
   * :oe:func:`OESpruce::OEGetExperimentTypeName` function
