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

.. oe:namespace:: OESpruce

..  _OESpruce_OESequenceMetadataToJson:

.. oe:function:: OESequenceMetadataToJson

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         std::string OESequenceMetadataToJson(const OESequenceMetadata& metadata,
                                              const bool prettyPrint = true)

   .. oe:language:: python

      .. oe:api:: python

         OESequenceMetadataToJson(metadata: OESequenceMetadata,
                                  prettyPrint: bool = True) -> str

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

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

      * - Field
        - Type
        - Description
      * - ``ChainID``
        - string
        - Chain identifier for this sequence segment.
      * - ``StartResNum``
        - integer
        - Residue number of the first residue in the sequence segment.
      * - ``StartResInsCode``
        - string (single character)
        - Insertion code of the first residue in the sequence segment.
      * - ``EndResNum``
        - integer
        - Residue number of the last residue in the sequence segment.
      * - ``EndResInsCode``
        - string (single character)
        - Insertion code of the last residue in the sequence segment.
      * - ``Sequence``
        - string
        - One-letter amino acid sequence for this segment.

   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::OESequenceMetadataFromJson` function
   * :oe:cls:`OESpruce::OESequenceMetadata` class
