diff --git a/avogadro/io/cjsonformat.cpp b/avogadro/io/cjsonformat.cpp index fb578b55fc..2d2363487b 100644 --- a/avogadro/io/cjsonformat.cpp +++ b/avogadro/io/cjsonformat.cpp @@ -214,21 +214,6 @@ bool CjsonFormat::deserialize(std::istream& file, Molecule& molecule, } } - // Partial charges are optional, but if present should be loaded. - json partialCharges = atoms["partialCharges"]; - if (partialCharges.is_object()) { - // keys are types, values are arrays of charges - for (auto& kv : partialCharges.items()) { - MatrixX charges(atomCount, 1); - if (isNumericArray(kv.value()) && kv.value().size() == atomCount) { - for (size_t i = 0; i < kv.value().size(); ++i) { - charges(i, 0) = kv.value()[i]; - } - molecule.setPartialCharges(kv.key(), charges); - } - } - } - // Bonds are optional, but if present should be loaded. json bonds = jsonRoot["bonds"]; if (bonds.is_object() && isNumericArray(bonds["connections"]["index"])) { @@ -609,6 +594,21 @@ bool CjsonFormat::deserialize(std::istream& file, Molecule& molecule, } } + // Partial charges are optional, but if present should be loaded. + json partialCharges = atoms["partialCharges"]; + if (partialCharges.is_object()) { + // keys are types, values are arrays of charges + for (auto& kv : partialCharges.items()) { + MatrixX charges(atomCount, 1); + if (isNumericArray(kv.value()) && kv.value().size() == atomCount) { + for (size_t i = 0; i < kv.value().size(); ++i) { + charges(i, 0) = kv.value()[i]; + } + molecule.setPartialCharges(kv.key(), charges); + } + } + } + if (jsonRoot.find("layer") != jsonRoot.end()) { auto names = LayerManager::getMoleculeInfo(&molecule); json visible = jsonRoot["layer"]["visible"];