Skip to content

Commit

Permalink
Fix reading properties from CJSON (e.g., energies, etc.)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 11, 2024
1 parent de0b62f commit 1805b36
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions avogadro/io/cjsonformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>());
} else if (element.value().type() == json::value_t::number_integer) {
molecule.setData(element.key(), element.value().get<int>());
} else if (element.value().type() == json::value_t::boolean) {
molecule.setData(element.key(), element.value().get<bool>());
} else if (element.value().type() == json::value_t::string) {
molecule.setData(element.key(), element.value().get<std::string>());
} 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;
}
}
}
Expand Down

0 comments on commit 1805b36

Please sign in to comment.