From 1805b36987bd2acdb35e2057b1d38226cba1e327 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Tue, 10 Dec 2024 23:04:46 -0500 Subject: [PATCH] Fix reading properties from CJSON (e.g., energies, etc.) Signed-off-by: Geoff Hutchison --- avogadro/io/cjsonformat.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/avogadro/io/cjsonformat.cpp b/avogadro/io/cjsonformat.cpp index 52bcf06354..3c32446f44 100644 --- a/avogadro/io/cjsonformat.cpp +++ b/avogadro/io/cjsonformat.cpp @@ -667,11 +667,18 @@ bool CjsonFormat::deserialize(std::istream& file, Molecule& molecule, // std::cout << " property: " << element.key() << " = " << matrix // << " size " << matrix.rows() << 'x' << matrix.cols() // << std::endl; + } else if (element.value().type() == json::value_t::number_float) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::number_integer) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::boolean) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::string) { + molecule.setData(element.key(), element.value().get()); } else { - molecule.setData(element.key(), element.value()); - // std::cout << " property: " << element.key() << " = " - // << element.value() << " type " - // << element.value().type_name() << std::endl; + std::cout << " cannot store property: " << element.key() << " = " + << element.value() << " type " + << element.value().type_name() << std::endl; } } }