ignoring empty names...

master
Steffen Pohle 2 weeks ago
parent 58ff5bee62
commit ae4c001ce1

@ -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:

@ -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<JSONElement> *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;
}

Loading…
Cancel
Save