RBNSR v0.1
A Store Lua Tables /w Roblox Datatypes.
What is this?
This module acts as a solution, to save all Roblox datatypes in a custom format (A Normal Table). This can act as more of an optimized solution if you dont need to store an entire instance.
If you DO Want to store entire instances, i’d recommned finding my other module here:
What is serialization?
Serilization is basically the abililty of saving certain datatypes into a object or differnt structure. Learn more about it here :
What DataTypes are supported?
Summary
- String
- BinaryString
- Content
- ProtectedString
- UDim
- UDim2
- CFrame
- CoordianteFrame
- Boolean
- Float
- Number
- Int
- Int16
- Int32
- Int64
- ALL Enums!
- Faces
- BrickColor
- Vector3
- Vector2
- Color3
- Rect
- PhysicalProperties
- NumberRange
- Vector2int16
- Vector3int16
- ColorSequence
- ColorSequenceKeypoint
- NumberSequence
- NumberSequenceKeypoint
Limitations/Rules
-
Unlike JSON, rbnsr can story any dictonary with a valid index including roblox datatypes. Yes Mixed Tables work. You can even index with tables.
-
RBNSR is 130% bigger than json, however this is mostly due to rbnsr storing every index and value, however roblox datatypes usally take no more than 10bytes to store. ( 90% Of the time will be smaller than serializing inside json ).
How to use!
Using rbnsr, is just like using :JSONEncode
and JSONDecode
, expect it uses two methods Serialize
and Deserialize
Firstly, require the module, and create a table to encode.
-- Heres an
local toEncode = {
["ComplicatedDataType"] = ColorSequence.new{
ColorSequenceKeypoint.new(0,Color3.new(0.368627, 1, 0.270588)),
ColorSequenceKeypoint.new(1,Color3.new(1, 0.0666667, 0)),
},
[Vector3.new(1,5,3)] = {
["VectorIndex"] = 1
},
["StringIndex"] = {
"MixedTables",
["StringIndex"] = "MixedTables"
},
VectorValue = Vector3.new(1,2,3)
}
local rbnsr = require(game.ServerScriptService.rbnsr)
Now Serialize/Deserailze
local encoded = rbnsr.Serialize(toEncode)
-- now to decode
local decodedTable = rbnsr.Deserialize(encoded)
-- Now! toEncode == decodedTable
print("Compare:",toEncode,decodedTable)
And thats it! rbnsr can easily replace any jsonencode call without any extra setup.
Latest Version!