How do i read table output like the one in the studio?


I’m encountering a bug only found in game and not studio I looked for a way to read the table output. How to read table output - #7 by anthropomorphic_dev and Why does my table come out in a table: lh123loffg423123 way? - #14 by SquarePapyrus12 that both say to disable the log mode on the left but the button is not there.
Tables can only be read without any problems use the Output Tab, is you’d like to view it using the Console (which does not deserialize tables) you’ll have to make your own.
Here’s one I made
-- Makes a table readable
function deserialize(tb: {any}): string
local function serializeHelper(tbl: {any}, indent: number): string
local result = "{\n"
local indentStr = string.rep(" ", indent)
for key, value in pairs(tbl) do
local keyStr = (type(key) == "string") and `["{key}"]` or `[{tostring(key)}]`
if typeof(value) == "table" then
result ..= indentStr .. keyStr .. " = " .. serializeHelper(value, indent + 1) .. ",\n"
elseif typeof(value) == "string" then
result ..= indentStr .. keyStr .. ` = "{value}",\n`
else
result ..= indentStr .. keyStr .. " = " .. tostring(value) .. ",\n"
end
end
return result .. string.rep(" ", indent - 1) .. "}"
end
return serializeHelper(tb, 1)
end
local ExampleTable = {
User1 = {1,2,3},
User2 = {2,3,1},
User3 = {3,2,1}
}
print("-- SERIALIZED")
print(ExampleTable)
print("----------")
print(`{ExampleTable}`) -- eg, table:0x12rbu3f
print("-- DE-SERIALIZED")
print(deserialize(ExampleTable))
print("----------")
print(`{deserialize(ExampleTable)}`) -- gives exact result.
1 Like