Can you use JSONENCODE to save Dictionaries to datastore

for example
local dss = game:GetService(“DataStoreServiec”):GetDataStore(“ABC-123”)

local data = {
1 = {x, y, z},
2 = {x, y, z},
3 = {x,y,z}
}

– json encode data

dss:SetAsync(“Structures”, data) – data is now the json encoded data.

I thinl you can do it,
Almost sure, correct me if I’m wrong, anyway, why not testing it though?

Yes, it is possible to encode your dictionary using JSONEncode and save it to a DataStore safely.

1 Like

I believe data is already encoded in JSON for you and thus you are not actually doing anything by encoding it in JSON before saving.

1 Like

Yes you can save strings but you can also save tables in datastores so there is no need for encoding.

3 Likes

Datastores themselves already encodes a table using JSON so its unnecessary, just directly save the table.

But i cannot save dictionaries to datastores…

2 Likes

You can save dictionaries in datastores, the only thing is that the keys cannot be mixed, meaning it either has to be an array or dictionary with only string keys.

1 Like

I believe you’re talking about trying to save instances or userdata values then. Those are definitely not saveable but you can save them using serialization.