From 5a7624e50f8ea329046711a1c75bdd5c4e3fe932 Mon Sep 17 00:00:00 2001 From: Jakub Mateusz Marcowski <01158831@pw.edu.pl> Date: Wed, 1 Mar 2023 19:04:38 +0100 Subject: Modify JSON.stringify so that it doesn't create unnecessary empty lines from empty arrays (cherry picked from commit 0a55a320857b5ddb8ba4e3b6c096acf617f24733) --- core/io/json.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core') 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()); -- cgit v1.2.3