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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user