Browse Source

Util: Fix Serializer trailing commas in Object dumping

The .end() returns an iterator one past the last pair, so it would
always add a comma after the last member.
master
Riyyi 2 years ago
parent
commit
097be4c012
  1. 3
      src/util/json/serializer.cpp

3
src/util/json/serializer.cpp

@ -5,6 +5,7 @@
*/ */
#include <cstdint> // uint32_t #include <cstdint> // uint32_t
#include <iterator> // prev
#include <sstream> // ostringstream #include <sstream> // ostringstream
#include <string> #include <string>
@ -119,7 +120,7 @@ std::string Serializer::dumpObject(const Value& value, const uint32_t indentLeve
result += dumpHelper(it->second, indentLevel + 1); result += dumpHelper(it->second, indentLevel + 1);
// Add comma, except after the last element // Add comma, except after the last element
if (it != members.end()) { if (it != std::prev(members.end(), 1)) {
result += ","; result += ",";
} }
if (m_indent > 0) { if (m_indent > 0) {

Loading…
Cancel
Save