1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Reworked JsonNode constructors to more logical form

This commit is contained in:
Ivan Savenko
2024-02-13 13:18:10 +02:00
parent 54796c7c56
commit 08a27663f9
25 changed files with 125 additions and 161 deletions

View File

@@ -60,11 +60,7 @@ void JsonSerializer::serializeInternal(const std::string & fieldName, std::vecto
data.reserve(value.size());
for(const si32 rawId : value)
{
JsonNode jsonElement(JsonNode::JsonType::DATA_STRING);
jsonElement.String() = encoder(rawId);
data.push_back(std::move(jsonElement));
}
data.emplace_back(rawId);
}
void JsonSerializer::serializeInternal(const std::string & fieldName, std::vector<std::string> & value)
@@ -76,11 +72,7 @@ void JsonSerializer::serializeInternal(const std::string & fieldName, std::vecto
data.reserve(value.size());
for(const auto & rawId : value)
{
JsonNode jsonElement(JsonNode::JsonType::DATA_STRING);
jsonElement.String() = rawId;
data.push_back(std::move(jsonElement));
}
data.emplace_back(rawId);
}
void JsonSerializer::serializeInternal(std::string & value)
@@ -183,11 +175,7 @@ void JsonSerializer::writeLICPartBuffer(const std::string & fieldName, const std
auto & target = currentObject->operator[](fieldName)[partName].Vector();
for(auto & s : buffer)
{
JsonNode val(JsonNode::JsonType::DATA_STRING);
std::swap(val.String(), s);
target.push_back(std::move(val));
}
target.emplace_back(s);
}
}