5 #ifndef SERIALIZATION_H
6 #define SERIALIZATION_H
21 void to_json(json& j,
const MatrixBase<T>& matrix)
23 for (
int row = 0; row < matrix.rows(); ++row)
25 json column = json::array();
26 for (
int col = 0; col < matrix.cols(); ++col)
28 column.push_back(matrix(row, col));
35 void from_json(
const json& j, Matrix<T, Dynamic, Dynamic>& matrix)
37 if (j.size() == 0)
return;
38 matrix.resize(j.size(), j.at(0).size());
39 for (std::size_t row = 0; row < j.size(); ++row)
41 const auto& jrow = j.at(row);
42 for (std::size_t col = 0; col < jrow.size(); ++col)
44 const auto& value = jrow.at(col);
45 value.get_to(matrix(row, col));
52 void from_json(
const json& j, Matrix<T, Dynamic, 1>& V)
55 for (
int i = 0 ;
i < j.size(); ++
i)
void to_json(json &j, const MatrixBase< T > &matrix)
void from_json(const json &j, Matrix< T, Dynamic, Dynamic > &matrix)