1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Json Serializer should now use identifers storage properly

This commit is contained in:
Ivan Savenko
2023-09-04 22:23:20 +03:00
parent 9735fa6d06
commit b6a1a8f0da
10 changed files with 189 additions and 112 deletions

View File

@ -63,9 +63,25 @@ void JsonSerializer::serializeInternal(const std::string & fieldName, std::vecto
for(const si32 rawId : value)
{
JsonNode jsonElement(JsonNode::JsonType::DATA_STRING);
jsonElement.String() = encoder(rawId);
data.push_back(std::move(jsonElement));
JsonNode jsonElement(JsonNode::JsonType::DATA_STRING);
jsonElement.String() = encoder(rawId);
data.push_back(std::move(jsonElement));
}
}
void JsonSerializer::serializeInternal(const std::string & fieldName, std::vector<std::string> & value)
{
if(value.empty())
return;
JsonVector & data = currentObject->operator[](fieldName).Vector();
data.reserve(value.size());
for(const auto & rawId : value)
{
JsonNode jsonElement(JsonNode::JsonType::DATA_STRING);
jsonElement.String() = rawId;
data.push_back(std::move(jsonElement));
}
}