diff --git a/Changelog b/Changelog index 5c3c4b9..362d0a4 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +2026-08-02: +- JSON to string reports wired to JSON_T_NONE types. + also empty names? - we will ignore these. + Version 0.4: ============= 2026-06-09: diff --git a/json.cc b/json.cc index d44b9e3..94f468d 100644 --- a/json.cc +++ b/json.cc @@ -419,6 +419,7 @@ std::string JSONParse::ToString() { output = "{"; for (level = 1, iter = names.begin(); iter != names.end(); iter++) { + if (iter->name.length() == 0) continue; if (iter != names.begin()) output += ","; output += "\n"; for (i = 0; i < 4*level; i++) output += " "; @@ -548,6 +549,7 @@ void JSONElement::SetArray (std::string n, std::list *l) { type = JSON_T_ARRAY; for (iter = l->begin(); iter != l->end(); iter++) { + if (iter->name.length() == 0) continue; if (iter != l->begin()) value += ","; value += iter->GetString(); } @@ -586,6 +588,9 @@ void JSONElement::SetObject (std::string n, std::string s) { std::string JSONElement::GetString () { std::string output = ""; std::string filename = __FILE__; + + if (name.length() == 0) return ""; + if (type == JSON_T_NONE) return ""; switch (type) { case(JSON_T_NUMBER): @@ -613,7 +618,7 @@ std::string JSONElement::GetString () { else output += "\"" + name + "\" : " + value; break; default: - output += "\"error\" : \""+ filename + ":" + std::to_string(__LINE__) + output += "\"error\" : \"name:" + name + " source:" + filename + ":" + std::to_string(__LINE__) +" JSONElement unknown type error ("+std::to_string(type)+")\""; break; }