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, 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 / pastebin / pastebinlink or even through a JSON-Encoded-table (which you can also archive with HTTPService:JSONDecode())

The module is uploaded on my 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)
  • HTTP-Service must be enabled:
    (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:

  • The string-table

  • Pastebin string-table / Pastebinlink

  • JSON Encoded string-table

  • require(15301898379).StringTableToTable(stringTableHere)

Examples on how you could use it:
(The table in the pastebin is structured like a normal table format):

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

Let’s try getting it from the pastebin with the module!

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

Output:

5 ← (Apple from SpecialTree)

Great!
Let’s try that now from another 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 pastebin with the module!

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

Output:

3 ← (Banana from SpecialTree)

Keep in mind

  • Pastebin links will be automatically converted into raw links incase they aren’t by my module.
  • 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(15301898379).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, 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.

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 TraderBey’s String Table to Table Converter - Roblox

(Feedbacks are welcome.) :slightly_smiling_face:

-UPDATES
Last update (more of a bug fix) made on 01/03/2024:

  • The module works now with every link and not only pastebin.com

  • Supports now pastes.io where applicableDomains will be converted into /raw 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 script are now:

  1. StringTable / Link. (Same)
  2. A boolean for the warning output (New, is automatically true if not included)

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

Goodbye!

7 Likes

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

4 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:

3 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?

1 Like

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.

3 Likes

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

also this belongs in #resources:community-resources

1 Like