diff --git a/platform/script-debugger/backend/src/ValueModifierUtil.kt b/platform/script-debugger/backend/src/ValueModifierUtil.kt index fcabbec1be3c..9abd7ee5c71b 100644 --- a/platform/script-debugger/backend/src/ValueModifierUtil.kt +++ b/platform/script-debugger/backend/src/ValueModifierUtil.kt @@ -59,20 +59,20 @@ object ValueModifierUtil { } private fun doAppendName(builder: StringBuilder, name: String, quoted: Boolean) { - val useKeyNotation = !quoted && KEY_NOTATION_PROPERTY_NAME_PATTERN.matcher(name).matches() - if (builder.length != 0) { - builder.append(if (useKeyNotation) '.' else '[') - } - if (useKeyNotation) { - builder.append(name) - } - else { - if (quoted) { - builder.append(name) + val isProperty = !builder.isEmpty() + if (isProperty) { + val useKeyNotation = !quoted && KEY_NOTATION_PROPERTY_NAME_PATTERN.matcher(name).matches() + if (useKeyNotation) { + builder.append('.').append(name) } else { - JsonUtil.escape(name, builder) + builder.append('[') + if (quoted) builder.append(name) + else JsonUtil.escape(name, builder) + builder.append(']') } - builder.append(']') + } + else { + builder.append(name) } } \ No newline at end of file