move every from_json over to use at
This commit is contained in:
2024-08-27 17:25:32 +02:00
parent e8f9bc20aa
commit a329fd3f03
4 changed files with 12 additions and 13 deletions
+3 -3
View File
@@ -30,9 +30,9 @@ void UI_dial::from_json(const json& j)
{ {
UI_item::from_json(j); UI_item::from_json(j);
this->m_min = j["min"]; this->m_min = j.at("min");
this->m_max = j["max"]; this->m_max = j.at("max");
this->m_value = j["value"]; this->m_value = j.at("value");
} }
json UI_dial::to_json() const json UI_dial::to_json() const
+3 -3
View File
@@ -35,9 +35,9 @@ void UI_slider::from_json(const json& j)
{ {
UI_item::from_json(j); UI_item::from_json(j);
this->m_min = j["min"]; this->m_min = j.at("min");
this->m_max = j["max"]; this->m_max = j.at("max");
this->m_value = j["value"]; this->m_value = j.at("value");
} }
json UI_slider::to_json() const json UI_slider::to_json() const
+1 -1
View File
@@ -24,7 +24,7 @@ std::string UI_textbox::hint() const
void UI_textbox::from_json(const json& j) void UI_textbox::from_json(const json& j)
{ {
UI_item::from_json(j); UI_item::from_json(j);
m_hint = j["hint"]; m_hint = j.at("hint");
} }
json UI_textbox::to_json() const json UI_textbox::to_json() const
+5 -6
View File
@@ -74,15 +74,14 @@ void UI_thermo::from_json(const json& j)
{ {
UI_item::from_json(j); UI_item::from_json(j);
this->m_min = j["min"]; this->m_min = j.at("min");
this->m_max = j["max"]; this->m_max = j.at("max");
this->m_value = j["value"]; this->m_value = j.at("value");
this->m_color_map.clear(); this->m_color_map.clear();
for (auto& i : j["color_map"]) for (auto& i : j["color_map"])
{ {
double k = i["key"]; double k = i.at("key");
std::string c; std::string c = i.at("value");
i["value"].get_to(c);
this->m_color_map[k] = Color(c); this->m_color_map[k] = Color(c);
} }
} }