Hello guys. I’m trying to make saving system. I’m trying to save as much things as possible with roblox DataStores, but also not forgetting about loading speed. I know that there’s JSONEncode and Decode exist, and it convert any table/dictionary to string. But also, I know that I can make smth like this myself, with strings.
Some examples what I can achieve with JSON and String:
String:
Example of saved string:
"34F|10,8,-5,1,0,0,0,1,0,0,0,1;1;1,100;21,10;5,16|3,51;81,52|;"
ID_of_item|CFrame;Prop Level;n-materials and their amount in pairs|additional properties|;
--additional properties are stored inside item, or time for things like furnace
-ClassName in this example is Model which can be in ReplicatedStorage
(Pretty hard to understand string format, but cursed things like this can greatelly decrease memory usage, because single character uses 8 bit. And converting items to ID will decrease character amount)
JSON:
Example of saved JSON:
'{"341":[[10,8,-5,1,0,0,0,1,0,0,0,1,1,1,100,21,10,5,16],[3,51,81,52]]}'
Almost same things as above, but encoded with JSON.
As you can see here, Strings will be shorter. But IDK how much time they will spend. Strings will need:
- Convert prop to it’s ID
- Convert prop ID to string
- Find in some array what properties should be saved
- Convert needed properties to string
- Convert additional properties to string, if they exist
- Concatenate everything together with separators
|
JSON will need:
- Convert prop to it’s ID
- Find params which need be saved
- Find additional properties, if they exist
- Put to dictionary: [ID]={{Params}, {AdditionalParams}}
- Encode dictionary with JSON
So, I got question:
What will be faster:
- String manipulations
- JSON usage