function tableToString(studentNum)
local str = "{ "
str = str.."\n"
for k, v in pairs(studentNum) do
if type(v) ~= "table" then
str = str.."[\""..k.."\"]"
str = str..":"
str = str..v
str = str..","
str = str.."\n"
else
str = str.."[\""..k.."\"]"
str = str..":"
str = str..tableToString(v)
str = str..","
str = str.."\n"
end
end
str = string.sub(str, 1, -3)
str = str.."\n"
str = str .." }"
return str
-- print("tableToString===", str)
end
local studentNum = {1, {6, 7, {"hello", "world"}}, 5}
local str = tableToString(studentNum)
print(str)