String Table to Table Converter (Module)

Greetings and welcome to this small tutorial!

If you’ve encountered difficulties extracting a Roblox lua-table from a string, then you’re in the right place as I have developed a module specifically designed to getting that actual Roblox lua-table from a string using a better loadstring alternative method, so that other people don’t have to go through the pain.

This converter is designed to get the actual lua-table from a string-table, raw link or even through a JSON-Encoded-table (which you can also archive with HTTPService:JSONDecode())

The module is uploaded on my current main account’s profile and has been made open-source (published incase of updates), meaning that you can simply require it by using the following require method (below):

Requirements:

  • The module (Obviously as a source)

  • HTTP-Service must be enabled if you work with links:
    (to be able to access third-party-requested links and use them inside the module)

How to use it:

First you have to require the module and use the module.StringTableToTable function, then you put in the “stringTableHere” either one of these following things:

  • A string-table

  • A raw link

  • A JSON Encoded string-table

  • require(113691930527921).StringTableToTable(stringTableHere)

Examples on how you could use it:

(The table in the pastebin is structured like a normal lua-table format):

{
	["SpecialTree"] = {
		["Apple"] = 5,
		["Banana"] = 3,
		["Nuts"] = 4
	}
}

Let’s try getting it from a raw link (pastebin) with the module!

local result = require(113691930527921).StringTableToTable("https://pastebin.com/gKa8bR0x")
print(result.SpecialTree.Apple)

Output:

5 ← (Apple from SpecialTree)

Great!
Let’s try that now from another raw link (pastebin) that is this time structured into the Encoded JSON format:

(The table in the pastebin is this time structured in an Encoded JSON table format):

{"SpecialTree":{"Apple":5,"Banana":3,"Nuts":4}}

Let’s try getting it from the raw link (pastebin) with the module!

local result = require(113691930527921).StringTableToTable("https://pastebin.com/xd4F0feH")
print(result.SpecialTree.Banana)

Output:

3 ← (Banana from SpecialTree)

Keep in mind

  • Links will be automatically converted into /raw links incase they aren’t by my module if supported in the applicableDomains list ONLY if boolTryToFixLink (the second argument) is considered true.

  • Using HTTPService:GetAsync() is willing to return the information as a string, which when you have a table inside that information we then consider as a string-table. That’s why I made this module so we don’t have to deal with that problem and we can easily get the actual lua-table back with the help of my module!
    (So it will be “readable” for lua) :smile:

Now let’s try something different instead of using pastebin…

local StringTable = [[{
	["Name"] = "John",
	["Job"] = "Police Officer",
	["Level"] = 32
}]]

local result = require(113691930527921).StringTableToTable(StringTable)
local Name = result.Name
local Job = result.Job
local Level = result.Level

print("Name: "..Name.." / ".."Job: "..Job.." / ".."Level: "..Level)

Output:

Name: John / Job: Police Officer / Level: 32

And that’s it!
The module will then (if used correctly) return the string table to an actual Roblox lua-table that you can use further. If the string table contains an invalid format then it warns the error out (depending if boolWarnErrorInfo is true), and usually returns the table to nil to prevent script errors.

Why did I make this module?

  • Because I’ve seen a lot of people that have been using Roblox’s .LoadStringEnabled method which is a working one BUT extremly unsafe method at the same time, as it simply makes exploiters vulnerable to use loadstring() to take control of the game if used uncorrectly.

  • I also made this module because I know that a lot of people love to use the normal lua-table format, as it may be simpler to-use, are used to work with them, and may be better readable than a JSON table.

  • And most importantly, to keep everything orginized and have access to everything at once, basically (All-In-One).

For what would this be useful?

  • This would be extremly useful for making list-themed scripts (like a ban list e.g) via third party sites such as: (Pastebins for example).

Thank you for making it this far of this tutorial, I hope you enjoyed this short tutorial on how to use Bey’s String Table to Table Converter - Roblox

(Feedbacks are welcome.) :slightly_smiling_face:

-UPDATES

Lastest update made on 16/10/2024:

  • As of the 10/17/2024 I have inserted 2 giant maps inside the Module as Roblox keeps on denying Appeals on the Asset even though it’s clearly not “Misusing Roblox’s Systems”, which didn’t work out too, but now as of the 10/22/2024 it seems that Roblox may have improved the way they moderate models and the Module is now finally public!

  • Reuploaded the module due to my false account terminations incident and almost rescripted the entire logic, as the module used to be sort of broken & outdated due to the Luau Module that I had overwritten last time, because of how good it currently is and also made a bunch of improvements

  • Added support for a popular raw link domain snippet.host

  • Improved Devforum post (formatting, writing, new title, etc…)

Update (more of a bug fix) made on 01/03/2024:

  • The module works now with every link, not only from applicableDomains

  • Supports now pastes.io where applicableDomains will be converted into proper /raw links if not included (pastebin alternative since I noticed that pastebin goes rarely down and is not available in certain countries)

Current and possible arguments for the module:

  1. stringTable → (string-table / Raw link / JSON-Encoded-table).

  2. boolTryToFixLink → A boolean for fixing raw links properly through the tryFixingLink function (By default true)

  3. boolWarnErrorInfo → A boolean for the warning & error output (By default true)

Have fun using my module and stay safe! :wink:

Goodbye!

8 Likes

You mentioned JSONDecode/Encode. Why is your module better than using these methods? Why recreate something that is already builtin?

5 Likes

TL;DR: Misunderstood but even true

I never said that my module was better in JSONDecode/Encoding than the Roblox built-in, but it may be even the case due to the fact that it actually warns errors and returns a nil table.

Now isn’t it better to have all-in-one? Think about this:
Roblox has as you mentioned a JSONDecode/Encode built-in function, but not a String-Table-to-Table function, so I made this very nice and simple module, which I then decided to publish for other people to-use (open-source)!

Using my module will allow you to JSONDecode/Encode while being able to “Decode String Tables” as well which I mean with (All-In-One) :wink:

4 Likes

But those are literally the same thing… I’m so confused. Does your module even support datatypes like Color3, Vector3, and others that JSON doesn’t?

2 Likes

Well let’s find out if it does…

-- "But those are literally the same thing… I’m so confused. Does your module even support datatypes like Color3, Vector3, and others that JSON doesn’t?"
-- lua table trying to get color3 and vector3 as you mentioned "datatypes"
local testingTable = [[{
	Color = Color3.new(1, 0, 0),  -- Color3 in a table
	Position = Vector3.new(10, 20, 30)  -- Vector3 in a table
}]]

local result = require(15301898379).StringTableToTable(testingTable)
print(result.Color) -- 1, 0, 0
print(result.Position) -- 10, 20, 30
-- it works.

It literally works like a Roblox table, but my module converts the string tables into basically a “lua readable” table.

I’m pretty sure that JSONDecode and my String-Table-to-Table module are not the same thing as I’m about to try it out and proof it to you:

-- A string table
local testingTable = [[{
	Color = Color3.new(1, 0, 0),  -- Color3 in a table
	Position = Vector3.new(10, 20, 30)  -- Vector3 in a table
}]]

-- JSON trying to decode the string table
game:GetService("HttpService"):JSONDecode(testingTable)

-- Output: Can't parse JSON
-- But my module would get it to work because as mentioend above, "All-In-One" :D

JSON table and a lua table are not the same as shown and proven above. They’re both handy for holding data, but they’ve got their own styles.

5 Likes

@bluebxrrybot is true, also I’d use JSON Tables over this

also this belongs in #resources:community-resources

2 Likes

It says I need permissions to view it.

2 Likes

Due to the new Violations & Appeals update, it’s difficult to upload Module scripts to the marketplace as Roblox uses bots to moderate these assets to take down Module scripts with long code which I know is stupid, but I have now tried to overwrite the Module and it seems to be approved (for now).

It currently seems that Roblox might have recently improved the way they moderate models which is quite nice and way better than before, if that’s the case.