Merge pull request #74170 from Chubercik/master

Modify JSON.stringify so that it doesn't create unnecessary empty lines from empty arrays
This commit is contained in:
Rémi Verschelde 2023-03-07 10:32:43 +01:00
commit e17b7ae223
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -91,9 +91,12 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_
case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::ARRAY: {
Array a = p_var;
if (a.size() == 0) {
return "[]";
}
String s = "[";
s += end_statement;
Array a = p_var;
ERR_FAIL_COND_V_MSG(p_markers.has(a.id()), "\"[...]\"", "Converting circular structure to JSON.");
p_markers.insert(a.id());