blueSerializer - serialize robloxs primitive types

blueserializer

serialize and deserialize roblox's primitive types

Github repository | Releases downloads and rbxm | Readmedotmd | wally package

Why?

Roblox has a thing called “primitive types”, If you dont know what these are, these are special values like Vector3. You use them alot in roblox development, even if you didn’t know.

But there are a few issues with these,

  1. Cant be saved in datastore
  2. Cant be transferred to remote events
  3. Etc

Serializing these values are the solution. But writing the serializers for these are a huge pain, so this small module will help.

ze famous examples

local blueSerializer = require(path.to.blueserializer)
local serialized = blueSerializer.serialize(Vector3.new(1, 5, 88))
print(serialized) -- >> {"V", 1, 5, 88}
print(blueSerializer.deserialize(serialized)) -- >> Vector3.new(1, 5, 88) or in the output 1, 5, 88
-- blueSerialize.deSerialize exists as an alias of blueSerializer.deserialize
local blueSerializer = require(path.to.blueserializer)
local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetDataStore("mypart")
local myPart = workspace.myPart
-- i want to save the part's position and the part's color3 in workspace
dataStore:SetAsync("mypart", {
    Position = blueSerializer.serialize(myPart.Position),
    Color3 = blueSerializer.serialize(myPart.Color3)
})

-- the loading
local dat = dataStore:GetAsync("mypart")
myPart.Position = blueSerializer.deserialize(dat.Position)
myPart.Color3 = blueSerializer.deserialize(dat.Color3)

-- note this is psuedo example code and is only supposed to represent the basic usage
-- of blue serializer

Supported primitive types for this module

Supported primitive types
CFrame
Vector3
Color3
EnumItem
BrickColor
TweenInfo
Vector2
Vector2int16
Vector3int16
UDim
UDim2
Region3
Region3int16
PhysicalProperties
Rect
NumberRange
Ray
DockWidgetPluginGuiInfo
PathwayPoint

(this list might mot be up to date or be updated frequently but you can read the serializerList.lua in module in the repo to see the supported primitive types)

Note

Not the most optimized serializer

Thanks and feedback is appreciated

23 Likes

Interesting concept you have here!

1 Like

Nice, now I don’t have to make an entire module for this in the future. Thanks, definitely gonna use this.

2 Likes

btw feel free to contribute, i want to add alot of roblox’s serializable primitive types or u can optimize anything, or just contribute anythin good.

1 Like

Special thanks to Someone-dQw4w9WgXcQ · GitHub for the merge request add types and optimise by Someone-dQw4w9WgXcQ · Pull Request #1 · commitblue/blueserializer · GitHub

Now there are types and you cant modify the module,

Update soon.

1 Like

Hey! I made a PR to add UDim and UDim2. Nice resource, I can see this being useful when storing data.

3 Likes

Can you add Reigon3? it’s a primitive type (despite being deprecated)

1 Like

Ill see If i can, thank you for suggesting.

1 Like

Thanks for @2jammers for adding UDim and UDim2 to the serializer.

1 Like

Here Ill make a PR for Region3

2 Likes

Made a PR for Rect, NumberRange, PhysicalProperties, Ray, DockWidgetPluginGuiInfo, PathWaypoint, and Region3int16. Also added proper typing to the deserializers and removed spaces between : in params.

Couldn’t figure out Region3 sadly.

2 Likes

I was able to make a region3 serializer but no deserializer sadly

1 Like

you and someone is doin much more work than me :skull:

seriously though i appreciate it, it was a dead resource for 6 months and you two revived it by the two prs, thx.

now an update is coming, tell me suggestions other than region3

2 Likes

Thanks to lolmansreturn for another pr, added Rect, NumberRange, PhysicalProperties, Axes, DockWidgetPluginGuiInfo, PathwayPoint.
And ray, region3, region3int16!!!

Nah it’s all good, was just bored.

About more types, not really sure at this point. Think we got pretty much all of them that aren’t deprecated lol. Also I added Region3int16 not Axes. Maybe add Axes?? Was looking here if you wanna know: Data type | Roblox Wiki | Fandom

I also added this to my framework!

1 Like

I will add Axes if its serializable, thanks for the pr

Edit: I think it is. Will add it soon.

1 Like

Made a PR for Font and Tuple, last one. Also removed id to type since it wasn’t being used, was an excuse to optimize.

sorry for the large amount pull requests, was gonna add font in the last one but forgot.

1 Like

I added a comment to your pr

Added Axes for the serializer. Now the wally package is updated.

uhh the Region3 isn’t fully added though…