Skip to content

Stringify Sub-Module Documentation⚓︎


Overview⚓︎

The Stringify sub-module consists of one function that converts a given table into a string value, similar to how tables are printed in Roblox Studio.

Functions⚓︎

Stringify⚓︎

Purpose⚓︎

Converts a given table to a good-looking string representation.

Syntax⚓︎

Stringify(Table: table, TabSize: number?, IndentionCharacter: string?, IsRecursive: boolean?, Cache: table?, CIndention: number?): boolean

Parameters⚓︎

  • Table: string
    The input table to convert.
  • IndentionSize: number Optional
    The size of the indentation in spaces/provided character if any.
    Default is 4.
  • IndentionCharacter: string Optional
    The character to use for indentation.
    Default is a space character " ".
  • Recursive: boolean Optional
    A boolean indicating whether to recursively process nested tables.
    Default is false.
  • Cache: table Optional
    A table to use as a cache to detect circular references1 (Used by the function's recursive calls).
  • CIndention: number Optional
    The current level of indentation (Used by the function's recursive calls).

Returns⚓︎

  • string
    The string representation of the given table.

Examples⚓︎

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local Table = {
    Name = "John",
    Age = 30,
    Hobbies = {"Reading", "Swimming", "Cooking"},
    Address = {
        Street = "123 Main Street",
        City = "New York",
        State = "NY",
        Zip = "10001"
    }
}
print(Stringify(Table))    -- Recursive parameter is not on/true

local Table = {
    ["Item 1"] = 123,
    ["Item 2"] = "Hello, world!",
    ["Item 3"] = true,
    ["Item 4"] = {
        ["Subitem 1"] = "Nested value",
        ["Subitem 2"] = false
    },
    ["Item 5"] = {
        [1] = "Array item 1",
        [2] = "Array item 2",
        [3] = "Array item 3"
    }
}
print(Stringify(Table, 4, " ", true))

local Table = { {1}, {2} }
print(String.Stringify(Table, nil, "-", true))
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
    ["Address"] = table: 0x8721c752aabb7911,
    ["Age"] = 30,
    ["Name"] = "John",
    ["Hobbies"] = table: 0x497b292a40db2041
}
{
    ["Item 1"] = 123,
    ["Item 2"] = "Hello, world!",
    ["Item 5"] = {
        [1] = "Array item 1",
        [2] = "Array item 2",
        [3] = "Array item 3"
    },
    ["Item 4"] = {
        ["Subitem 2"] = false,
        ["Subitem 1"] = "Nested value"
    },
    ["Item 3"] = true
}
{
----["1"] = {
--------[1] = 1
----},
----["2"] = {
--------[1] = 2
----}
}

  1. Circular reference is a situation in which two tables/values reference each other (e.g. table.__index = table).