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

.. oe:namespace:: OESpruce

..  _OESpruce_OEStructureMetadataFromJson:

.. oe:function:: OEStructureMetadataFromJson

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         bool OEStructureMetadataFromJson(OEStructureMetadata& metadata,
                                          const std::string& json)

   .. oe:language:: python

      .. oe:api:: python

         OEStructureMetadataFromJson(metadata: OEStructureMetadata, json: str) -> bool

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

   .. 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, resolved via :oe:func:`OESpruce::OEGetExperimentTypeID`.
      * - ``IridiumData``
        - object
        - Nested object containing Iridium quality assessment data.
      * - ``SequenceMetadata``
        - array of objects
        - Array of sequence segment objects, each parsed according to the fields documented in :oe:func:`OESpruce::OESequenceMetadataFromJson`.
      * - ``HeterogenMetadata``
        - array of objects
        - Array of heterogen objects, each parsed according to the fields documented in :oe:func:`OESpruce::OEHeterogenMetadataFromJson`.

   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.

   .. admonition:: Code Example

      * :ref:`spruce_examples_make_design_units_using_metadata` example

.. seealso::

   * :oe:func:`OESpruce::OEStructureMetadataToJson` function
   * :oe:func:`OESpruce::OESequenceMetadataFromJson` function
   * :oe:func:`OESpruce::OEHeterogenMetadataFromJson` function
   * :oe:cls:`OESpruce::OEStructureMetadata` class
   * :oe:func:`OESpruce::OEGetExperimentTypeID` function
