Use the standard JSON writer for tilestats

With a lot of weird special cases to keep the formatting
exactly like it accidentally was before
This commit is contained in:
Eric Fischer
2018-03-16 15:19:23 -07:00
parent 08fc2f281e
commit ebb0334ef0
3 changed files with 118 additions and 106 deletions
+15 -9
View File
@@ -28,6 +28,9 @@ void json_writer::json_adjust() {
if (wantnl) {
adds(",\n");
nospace = false;
} else if (nospace) {
addc(',');
nospace = false;
} else {
adds(", ");
}
@@ -43,6 +46,9 @@ void json_writer::json_adjust() {
if (wantnl) {
adds(",\n");
nospace = false;
} else if (nospace) {
addc(',');
nospace = false;
} else {
adds(", ");
}
@@ -116,17 +122,17 @@ void json_writer::json_end_hash() {
}
}
void json_writer::json_write_string(std::string const &s) {
void json_writer::json_write_string(std::string const &str) {
json_adjust();
addc('"');
for (size_t i = 0; i < s.size(); i++) {
if (s[i] == '\\' || s[i] == '"') {
aprintf("\\%c", s[i]);
} else if ((unsigned char) s[i] < ' ') {
aprintf("\\u%04x", s[i]);
for (size_t i = 0; i < str.size(); i++) {
if (str[i] == '\\' || str[i] == '"') {
aprintf("\\%c", str[i]);
} else if ((unsigned char) str[i] < ' ') {
aprintf("\\u%04x", str[i]);
} else {
addc(s[i]);
addc(str[i]);
}
}
addc('"');
@@ -157,10 +163,10 @@ void json_writer::json_write_signed(long long v) {
aprintf("%lld", v);
}
void json_writer::json_write_stringified(std::string const &s) {
void json_writer::json_write_stringified(std::string const &str) {
json_adjust();
adds(s);
adds(str);
}
void json_writer::json_write_bool(bool b) {