fix(json2lua): 修复非字符串数组元素的转换逻辑
- 增加对对象类型数组元素的处理 - 添加对其他类型数组元素的处理 - 优化了数组元素的缩进和换行
This commit is contained in:
@@ -20,8 +20,10 @@ function jsonToLua(jsonObj, indent = '', linefeed = '\n') {
|
|||||||
|
|
||||||
if (typeof item === 'string') {
|
if (typeof item === 'string') {
|
||||||
luaStr += `${indent} '${item}',`;
|
luaStr += `${indent} '${item}',`;
|
||||||
} else {
|
} else if (typeof item == 'object') {
|
||||||
luaStr += `{${jsonToLua(item, '', '')}},`;
|
luaStr += `{${jsonToLua(item, '', '')}},`;
|
||||||
|
} else {
|
||||||
|
luaStr += `${indent} ${item},`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
luaStr += `${indent}},\n`;
|
luaStr += `${indent}},\n`;
|
||||||
|
|||||||
Reference in New Issue
Block a user