14 #include <json/json.h>
24 Json::CharReaderBuilder builder;
25 const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
26 if (!reader->parse(json_str.c_str(), json_str.c_str() + json_str.length(),
34 return Json::writeString(Json::StreamWriterBuilder(), json);
40 return val.toStyledString();
44 const Json::Value &value) {
45 if (value.size() != 3) {
48 vec(0) = value[0].asDouble();
49 vec(1) = value[1].asDouble();
50 vec(2) = value[2].asDouble();
65 const Json::Value &value) {
66 if (value.size() != 4) {
69 vec(0) = value[0].asDouble();
70 vec(1) = value[1].asDouble();
71 vec(2) = value[2].asDouble();
72 vec(3) = value[3].asDouble();
88 const Json::Value &value) {
89 if (value.size() != 9) {
92 for (
int i = 0; i < 9; i++) {
93 mat.coeffRef(i) = value[i].asDouble();
100 Json::Value &value) {
102 for (
int i = 0; i < 9; i++) {
103 value.append(mat.coeffRef(i));
109 const Json::Value &value) {
110 if (value.size() != 16) {
113 for (
int i = 0; i < 16; i++) {
114 mat.coeffRef(i) = value[i].asDouble();
121 Json::Value &value) {
123 for (
int i = 0; i < 16; i++) {
124 value.append(mat.coeffRef(i));
130 const Json::Value &value) {
131 if (value.size() != 16) {
134 for (
int i = 0; i < 16; i++) {
135 mat.coeffRef(i) = value[i].asDouble();
142 Json::Value &value) {
144 for (
int i = 0; i < 16; i++) {
145 value.append(mat.coeffRef(i));
151 const Json::Value &value) {
152 if (value.size() != 36) {
155 for (
int i = 0; i < 36; i++) {
156 mat.coeffRef(i) = value[i].asDouble();
163 Json::Value &value) {
165 for (
int i = 0; i < 36; i++) {
166 value.append(mat.coeffRef(i));
172 const Json::Value &value) {
173 if (value.size() != 36) {
176 for (
int i = 0; i < 36; i++) {
177 mat.coeffRef(i) = value[i].asDouble();
184 Json::Value &value) {
186 for (
int i = 0; i < 36; i++) {
187 value.append(mat.coeffRef(i));
static bool EigenMatrix3dFromJsonArray(Eigen::Matrix3d &mat, const Json::Value &value)
static bool EigenVector3dFromJsonArray(Eigen::Vector3d &vec, const Json::Value &value)
static bool EigenVector3dToJsonArray(const Eigen::Vector3d &vec, Json::Value &value)
virtual bool ConvertToJsonValue(Json::Value &value) const =0
static bool EigenVector4dToJsonArray(const Eigen::Vector4d &vec, Json::Value &value)
static bool EigenMatrix6dFromJsonArray(Eigen::Matrix6d &mat, const Json::Value &value)
static bool EigenMatrix3dToJsonArray(const Eigen::Matrix3d &mat, Json::Value &value)
static bool EigenVector4dFromJsonArray(Eigen::Vector4d &vec, const Json::Value &value)
static bool EigenMatrix6dToJsonArray(const Eigen::Matrix6d &mat, Json::Value &value)
virtual std::string ToString() const
Convert to a styled string representation of JSON data for display.
static bool EigenMatrix4dFromJsonArray(Eigen::Matrix4d &mat, const Json::Value &value)
static bool EigenMatrix4dToJsonArray(const Eigen::Matrix4d &mat, Json::Value &value)
Eigen::Matrix< double, 6, 6, Eigen::DontAlign > Matrix6d_u
Eigen::Matrix< double, 4, 4, Eigen::DontAlign > Matrix4d_u
Eigen::Matrix< double, 6, 6 > Matrix6d
Extending Eigen namespace by adding frequently used matrix type.
Json::Value StringToJson(const std::string &json_str)
Parse string and conver to Json::value. Throws exception if the conversion is invalid.
std::string JsonToString(const Json::Value &json)
Serialize a Json::Value to a string.
Generic file read and write utility for python interface.