From a8bf0b6380b708d2c7ce4bb1170280e086d022a8 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 2 Jan 2025 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(json2lua):=20=E4=BF=AE=E5=A4=8D=E9=9D=9E?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=95=B0=E7=BB=84=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E7=9A=84=E8=BD=AC=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加对对象类型数组元素的处理 - 添加对其他类型数组元素的处理 - 优化了数组元素的缩进和换行 --- json2lua.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/json2lua.js b/json2lua.js index 78be4a3..11d2a04 100644 --- a/json2lua.js +++ b/json2lua.js @@ -20,8 +20,10 @@ function jsonToLua(jsonObj, indent = '', linefeed = '\n') { if (typeof item === 'string') { luaStr += `${indent} '${item}',`; - } else { + } else if (typeof item == 'object') { luaStr += `{${jsonToLua(item, '', '')}},`; + } else { + luaStr += `${indent} ${item},`; } }); luaStr += `${indent}},\n`;