25#include <SimoxUtility/algorithm/string/string_tools.h>
26#include <SimoxUtility/color/Color.h>
27#include <SimoxUtility/color/json.h>
28#include <SimoxUtility/json/util.h>
39#include <VisionX/libraries/armem_human/aron/Person.aron.generated.h>
44 template <
class ValueType>
45 std::optional<ValueType>
51 j.at(key).get_to(value);
52 return std::optional(value);
57 template <
class ValueType>
60 const std::string key,
61 const std::optional<ValueType> optional)
63 if (optional.has_value())
65 j[key] = optional.value();
72 j[
"firstName"] =
arondto.id.firstName;
73 j[
"lastName"] =
arondto.id.lastName;
85 j[
"attributes"] = simox::json::json::object();
89 j[
"physiologicalBiometrics"] =
arondto.physiologicalBiometrics;
90 j[
"previousInteractions"] =
arondto.previousInteractions;
91 j[
"preferences"] =
arondto.preferences;
92 j[
"abilities"] =
arondto.abilities;
93 j[
"medicalConditions"] =
arondto.medicalConditions;
94 j[
"customAttributes"] =
arondto.customAttributes;
95 j[
"customNotes"] =
arondto.customNotes;
101 using namespace simox::json;
103 ARMARX_INFO <<
"Converting profile from json to profile";
105 get_to_if_exists(j,
"firstName",
arondto.id.firstName);
106 get_to_if_exists(j,
"lastName",
arondto.id.lastName);
108 get_to_if_exists(j,
"names",
arondto.names);
110 get_to_if_exists(j,
"roles",
arondto.roles);
112 if (j.count(
"attributes"))
117 if (
auto dict = std::dynamic_pointer_cast<aron::data::Dict>(
data))
132 get_to_if_exists(j,
"physiologicalBiometrics",
arondto.physiologicalBiometrics);
133 get_to_if_exists(j,
"previousInteractions",
arondto.previousInteractions);
134 get_to_if_exists(j,
"preferences",
arondto.preferences);
135 get_to_if_exists(j,
"abilities",
arondto.abilities);
136 get_to_if_exists(j,
"medicalConditions",
arondto.medicalConditions);
137 get_to_if_exists(j,
"customAttributes",
arondto.customAttributes);
138 get_to_if_exists(j,
"customNotes",
arondto.customNotes);
144 j = simox::alg::to_lower(
arondto.toString());
150 arondto.fromString(simox::alg::to_upper(j.get<std::string>()));
156 j = simox::alg::to_lower(
arondto.toString());
162 arondto.fromString(simox::alg::to_upper(j.get<std::string>()));
169 j[
"handedness"] =
arondto.handedness;
178 using namespace simox::json;
180 get_to_if_exists(j,
"gender",
arondto.gender, Gender::DIVERSE);
181 get_to_if_exists(j,
"handedness",
arondto.handedness, Handedness::BOTH);
215 j[
"preferred"] =
arondto.preferred;
216 j[
"disliked"] =
arondto.disliked;
222 using namespace simox::json;
223 get_to_if_exists(j,
"preferred",
arondto.preferred);
224 get_to_if_exists(j,
"disliked",
arondto.disliked);
264 j[
"bedroom"] =
arondto.bedroom;
270 simox::json::get_to_if_exists(j,
"bedroom",
arondto.bedroom);
static void ConvertFromNlohmannJSON(data::VariantPtr &, const nlohmann::json &, const aron::type::VariantPtr &=nullptr)
static nlohmann::json ConvertToNlohmannJSON(const data::VariantPtr &)
#define ARMARX_INFO
The normal logging level.
std::shared_ptr< Variant > VariantPtr
void to_json(simox::json::json &j, const Gender &arondto)
void from_json(const simox::json::json &j, Gender &arondto)
std::optional< ValueType > opt_from_json(const simox::json::json &j, const std::string key)
void set_if_present(simox::json::json &j, const std::string key, const std::optional< ValueType > optional)