Added more get/put methods to json objects

This commit is contained in:
MihailRis
2023-11-10 21:26:09 +03:00
parent 65eb851fd8
commit b9ed7a2b28
2 changed files with 19 additions and 0 deletions
+16
View File
@@ -247,6 +247,13 @@ JArray& JArray::put(number_t value) {
return *this;
}
JArray& JArray::put(float value) {
valvalue val;
val.num = value;
values.push_back(new Value(valtype::number, val));
return *this;
}
JArray& JArray::put(bool value) {
valvalue val;
val.boolean = value;
@@ -286,6 +293,12 @@ void JObject::num(std::string key, number_t& dst) const {
dst = found->second->value.num;
}
void JObject::num(std::string key, float& dst) const {
auto found = map.find(key);
if (found != map.end())
dst = found->second->value.num;
}
void JObject::num(std::string key, int& dst) const {
auto found = map.find(key);
if (found != map.end())
@@ -326,6 +339,9 @@ JObject& JObject::put(string key, int value) {
return put(key, (number_t)value);
}
JObject& JObject::put(string key, float value) {
return put(key, (number_t)value);
}
JObject& JObject::put(string key, number_t value) {
auto found = map.find(key);