diff options
author | Jakub Mateusz Marcowski <01158831@pw.edu.pl> | 2023-03-01 19:04:38 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-14 13:59:03 +0100 |
commit | 5a7624e50f8ea329046711a1c75bdd5c4e3fe932 (patch) | |
tree | 55ffb1f793f406b4b7fffeaf9ee053e265e5e750 | |
parent | 7e74568709532181be3e803d64d22b8a03a45a9a (diff) |
Modify JSON.stringify so that it doesn't create unnecessary empty lines from empty arrays
(cherry picked from commit 0a55a320857b5ddb8ba4e3b6c096acf617f24733)
-rw-r--r-- | core/io/json.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/io/json.cpp b/core/io/json.cpp index 448e39b2c3..8d0fe53ed4 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -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()); |