diff --git a/SimoxUtility/json/converters.cpp b/SimoxUtility/json/converters.cpp index 9f3b234c4d5bdbe27c69b5af7b38013f4f085701..acd8f1e00824149848112a2088657bd586d48095 100644 --- a/SimoxUtility/json/converters.cpp +++ b/SimoxUtility/json/converters.cpp @@ -7,11 +7,11 @@ namespace simox { Eigen::Matrix4f json::posquat2eigen4f(const std::string& str) { - return posquat2eigen4f(::nlohmann::json::parse(str)); + return posquat2eigen4f(::simox::json::json::parse(str)); } Eigen::Matrix4f json::posquat2eigen4f(const char* str) { - return posquat2eigen4f(::nlohmann::json::parse(str)); + return posquat2eigen4f(::simox::json::json::parse(str)); } Eigen::Matrix4f json::posquat2eigen4f(const nlohmann::json& j) { @@ -28,11 +28,11 @@ namespace simox std::vector<Eigen::Matrix4f> json::posquatArray2eigen4fVector(const std::string& str) { - return posquatArray2eigen4fVector(::nlohmann::json::parse(str)); + return posquatArray2eigen4fVector(::simox::json::json::parse(str)); } std::vector<Eigen::Matrix4f> json::posquatArray2eigen4fVector(const char* str) { - return posquatArray2eigen4fVector(::nlohmann::json::parse(str)); + return posquatArray2eigen4fVector(::simox::json::json::parse(str)); } std::vector<Eigen::Matrix4f> json::posquatArray2eigen4fVector(const nlohmann::json& j) @@ -90,11 +90,11 @@ namespace simox std::map<std::string, float> json::json2NameValueMap(const std::string& str) { - return json2NameValueMap(::nlohmann::json::parse(str)); + return json2NameValueMap(::simox::json::json::parse(str)); } std::map<std::string, float> json::json2NameValueMap(const char* str) { - return json2NameValueMap(::nlohmann::json::parse(str)); + return json2NameValueMap(::simox::json::json::parse(str)); } std::map<std::string, float> json::json2NameValueMap(const nlohmann::json& j) { diff --git a/SimoxUtility/json/converters.h b/SimoxUtility/json/converters.h index 34c778c19009ca0c8839c9bbe5254d3e38b077db..8f1a65023656213f591b10f37ab8f4a4501f221b 100644 --- a/SimoxUtility/json/converters.h +++ b/SimoxUtility/json/converters.h @@ -5,23 +5,23 @@ #include <Eigen/Core> -#include "json.hpp" +#include "json.h" namespace simox::json { Eigen::Matrix4f posquat2eigen4f(const std::string& str); Eigen::Matrix4f posquat2eigen4f(const char* str); - Eigen::Matrix4f posquat2eigen4f(const nlohmann::json& j); + Eigen::Matrix4f posquat2eigen4f(const simox::json::json& j); std::vector<Eigen::Matrix4f> posquatArray2eigen4fVector(const std::string& str); std::vector<Eigen::Matrix4f> posquatArray2eigen4fVector(const char* str); - std::vector<Eigen::Matrix4f> posquatArray2eigen4fVector(const nlohmann::json& j); + std::vector<Eigen::Matrix4f> posquatArray2eigen4fVector(const simox::json::json& j); std::string eigen4f2posquatJson(const Eigen::Matrix4f& str); std::string eigen4fVector2posquatArrayJson(const std::vector<Eigen::Matrix4f>& str); std::map<std::string, float> json2NameValueMap(const std::string& str); std::map<std::string, float> json2NameValueMap(const char* str); - std::map<std::string, float> json2NameValueMap(const nlohmann::json& j); + std::map<std::string, float> json2NameValueMap(const simox::json::json& j); } diff --git a/SimoxUtility/json/eigen_conversion.cpp b/SimoxUtility/json/eigen_conversion.cpp index 23044671994debf89f1bb23197086b2e3f7f93fd..ed158b365c3a61fc5ea844c4e920e47c4f192303 100644 --- a/SimoxUtility/json/eigen_conversion.cpp +++ b/SimoxUtility/json/eigen_conversion.cpp @@ -8,7 +8,7 @@ namespace Eigen { template <> - void from_json<Eigen::Vector3f>(const nlohmann::json& j, Eigen::MatrixBase<Eigen::Vector3f>& vector) + void from_json<Eigen::Vector3f>(const ::simox::json::json& j, Eigen::MatrixBase<Eigen::Vector3f>& vector) { if (j.is_object()) { @@ -24,7 +24,7 @@ namespace Eigen template <> - void from_json<Eigen::Matrix4f>(const nlohmann::json& j, Eigen::MatrixBase<Eigen::Matrix4f>& matrix) + void from_json<Eigen::Matrix4f>(const ::simox::json::json& j, Eigen::MatrixBase<Eigen::Matrix4f>& matrix) { if (j.is_object()) { diff --git a/SimoxUtility/json/eigen_conversion.h b/SimoxUtility/json/eigen_conversion.h index 2dbb731c0c76643155e03678bb6f99d97e7aa506..d0a8162970fec5447a7406554c7068af20aa20d4 100644 --- a/SimoxUtility/json/eigen_conversion.h +++ b/SimoxUtility/json/eigen_conversion.h @@ -1,17 +1,18 @@ #pragma once -#include "json.hpp" - #include <Eigen/Core> +#include "json.h" + + /** - * Provide `to_json()` and `from_json()` overloads for `nlohmann::json`, + * Provide `to_json()` and `from_json()` overloads for `simox::json::json`, * which allows simple syntax like: * * @code * Eigen::Matrix3f in, out; * - * nlohmann::json j; + * simox::json::json j; * j = in; * out = j.get<Eigen::Matrix3f>(); * @endcode @@ -27,18 +28,18 @@ namespace Eigen /// Writes the matrix as list of rows. template <typename Derived> - void to_json(nlohmann::json& j, const Eigen::MatrixBase<Derived>& matrix); + void to_json(simox::json::json& j, const Eigen::MatrixBase<Derived>& matrix); /// Reads the matrix from list of rows. template <typename Derived> - void from_json(const nlohmann::json& j, Eigen::MatrixBase<Derived>& matrix); + void from_json(const simox::json::json& j, Eigen::MatrixBase<Derived>& matrix); // Specialization for Eigen::Vector3f (implemented in .cpp) /// If `j` is an object, reads vector from `x, y, z` keys. Otherwise, reads it as matrix. template <> - void from_json<Eigen::Vector3f>(const nlohmann::json& j, Eigen::MatrixBase<Eigen::Vector3f>& vector); + void from_json<Eigen::Vector3f>(const simox::json::json& j, Eigen::MatrixBase<Eigen::Vector3f>& vector); // Specialization for Eigen::Matrix4f as transformation matrix (implemented in .cpp). @@ -50,29 +51,29 @@ namespace Eigen * Otherweise, reads it from list of rows. */ template <> - void from_json<Eigen::Matrix4f>(const nlohmann::json& j, Eigen::MatrixBase<Eigen::Matrix4f>& matrix); + void from_json<Eigen::Matrix4f>(const simox::json::json& j, Eigen::MatrixBase<Eigen::Matrix4f>& matrix); // Eigen::Quaternion /// Writes the quaternion with `qw, qx, qy, qz` keys. template <typename Derived> - void to_json(nlohmann::json& j, const Eigen::QuaternionBase<Derived>& quat); + void to_json(simox::json::json& j, const Eigen::QuaternionBase<Derived>& quat); /// Reads the quaternion from `qw, qx, qy, qz` keys. template <typename Derived> - void from_json(const nlohmann::json& j, Eigen::QuaternionBase<Derived>& quat); + void from_json(const simox::json::json& j, Eigen::QuaternionBase<Derived>& quat); // Eigen::Transform (Isometry, Affine, ...) template <typename T, int N, int Type> - void to_json(nlohmann::json& j, const Eigen::Transform<T,N,Type>& transform) + void to_json(simox::json::json& j, const Eigen::Transform<T,N,Type>& transform) { to_json(j, transform.matrix()); } template <typename T, int N, int Type> - void from_json(const nlohmann::json& j, Eigen::Transform<T,N,Type>& transform) + void from_json(const simox::json::json& j, Eigen::Transform<T,N,Type>& transform) { from_json(j, transform.matrix()); } @@ -88,13 +89,13 @@ namespace jsonbase /// Writes the matrix as list of rows. template <typename Derived> - void to_json(nlohmann::json& j, const Eigen::MatrixBase<Derived>& matrix) + void to_json(simox::json::json& j, const Eigen::MatrixBase<Derived>& matrix) { for (int row = 0; row < matrix.rows(); ++row) { if (matrix.cols() > 1) { - nlohmann::json jrow = nlohmann::json::array(); + simox::json::json jrow = simox::json::json::array(); for (int col = 0; col < matrix.cols(); ++col) { jrow.push_back(matrix(row, col)); @@ -110,7 +111,7 @@ namespace jsonbase /// Reads the matrix from list of rows. template <typename Derived> - void from_json(const nlohmann::json& j, Eigen::MatrixBase<Derived>& matrix) + void from_json(const simox::json::json& j, Eigen::MatrixBase<Derived>& matrix) { using Scalar = typename Eigen::MatrixBase<Derived>::Scalar; using Index = typename Eigen::MatrixBase<Derived>::Index; @@ -136,20 +137,20 @@ namespace jsonbase template <typename Derived> - void to_json(nlohmann::json& j, const Eigen::MatrixBase<Derived>& matrix) + void to_json(simox::json::json& j, const Eigen::MatrixBase<Derived>& matrix) { jsonbase::to_json(j, matrix); } template <typename Derived> - void from_json(const nlohmann::json& j, Eigen::MatrixBase<Derived>& matrix) + void from_json(const simox::json::json& j, Eigen::MatrixBase<Derived>& matrix) { jsonbase::from_json(j, matrix); } template <typename Derived> - void to_json(nlohmann::json& j, const Eigen::QuaternionBase<Derived>& quat) + void to_json(simox::json::json& j, const Eigen::QuaternionBase<Derived>& quat) { j["qw"] = quat.w(); j["qx"] = quat.x(); @@ -158,7 +159,7 @@ namespace jsonbase } template <typename Derived> - void from_json(const nlohmann::json& j, Eigen::QuaternionBase<Derived>& quat) + void from_json(const simox::json::json& j, Eigen::QuaternionBase<Derived>& quat) { using Scalar = typename Eigen::QuaternionBase<Derived>::Scalar; quat.w() = j.at("qw").get<Scalar>();