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

.. oe:namespace:: OESpruce

..  _OESpruce_OESequenceMetadataFromJson:

.. oe:function:: OESequenceMetadataFromJson

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         bool OESequenceMetadataFromJson(OESequenceMetadata& metadata,
                                         const std::string& json)

   .. oe:language:: python

      .. oe:api:: python

         OESequenceMetadataFromJson(metadata: OESequenceMetadata, json: str) -> bool

   Populates an :oe:cls:`OESpruce::OESequenceMetadata` object from a JSON-formatted string.
   The function recognizes the following fields in the JSON object:

   .. 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.

   Unrecognized or missing fields are silently ignored. Returns ``true`` if the JSON string was
   successfully parsed as an object; returns ``false`` if the string is not valid JSON or does
   not represent a JSON object.

.. seealso::

   * :oe:func:`OESpruce::OESequenceMetadataToJson` function
   * :oe:cls:`OESpruce::OESequenceMetadata` class
