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

.. oe:namespace:: OESpruce

..  _OESpruce_OEHeterogenMetadataFromJson:

.. oe:function:: OEHeterogenMetadataFromJson

   .. attention::

      |TWOLANGUAGE|

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

      .. oe:api::

         bool OEHeterogenMetadataFromJson(OEHeterogenMetadata& metadata,
                                          const std::string& json)

   .. oe:language:: python

      .. oe:api:: python

         OEHeterogenMetadataFromJson(metadata: OEHeterogenMetadata, json: str) -> bool

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

   .. 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, resolved via :oe:func:`OESpruce::OEGetHeterogenTypeID`.
      * - ``Tautomers``
        - array of strings
        - SMILES strings of known tautomeric forms of the heterogen.

   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::OEHeterogenMetadataToJson` function
   * :oe:cls:`OESpruce::OEHeterogenMetadata` class
   * :oe:func:`OESpruce::OEGetHeterogenTypeID` function
