Q: vectorXd from_json()? I'm trying to implement json serialization of a class using eigen::VectorXd and nlohmann-json library. It's not a problem to store the class as JSON string. How to parse VectorXd from JSON? Is there an other library more suitable for this task?
#include "json.hpp"

class TransformationStep {
public:
  VectorXd support_vector;
  int number;

  TransformationStep(int number_param, VectorXd support_vectorParam) {
    number = number_param;
    support_vector = support_vectorParam;
  }

  ~TransformationStep() {
  }

  //json serialization
  void to_json(nlohmann::json &j);
  void from_json(const nlohmann::json &j);
};


void TransformationStep::to_json(nlohmann::json &j) {
  j["number"] = number;
  j["support_vector"] = support_vector;
}


void Ftf::from_json(const nlohmann::json &j)
{
    number = (j.at("number").get<int>());
    //support_vector = j["support_vector"].get<VectorXd>()); //???
}

------ output calling to_json(nlohmann::json &j) ------
{
  "number": 3,
  "support_vector": [
    -0.00036705693279489064,
    0.020505439899631835,
    0.3531380358938106,
    0.0017673029092790872,
    -0.9333248513057808,
    0.04670404618976708,
    -0.21905858722244081,
    -1.011945322347849,
    -0.09172040021815037,
    0.008526811888809391,
    0.05187648010664058
  ]
}


A: I came up with
void vector_from_json(VectorXd& vector, const nlohmann::json &j) {
  vector.resize(j.size());
  size_t element_index=0;
  for (const auto& element : j) {
    vector(element_index++) = (double) element;
  }
}

