Hello. I made a table that tables should be in that table and I saved that with encode and I don’t know how to load them when I load normally it prints [{“Taken”:true,“Date”:“1/3/2021”,“Artist”:“SpecialTimeGaming”,“ID”:6185839475,“Name”:null}]
and I exactly don’t know what to do to make it a table
Dictionaries are formatted this like
local newDictionary = {
["A value with a space"] = "Hello there",
aValueThatDoesntHaveASpace = "This is the DevForums"
aNumberValue = 4,
aBoolValue = false,
}
And arrays are formatted like this
local newArray = {"Hello There", 5, false}
What you have saved is a dictionary, and to my knowledge, that can’t be turned into an array
If you are talking about using JSONEncode you can use
local array = "[{“Taken”:true,“Date”:“1/3/2021”,“Artist”:“SpecialTimeGaming”,“ID”:6185839475,“Name”:null}]"
local httpService = game:GetService("HttpService")
local decodedTable = httpService:JSONDecode(array)
I am saving something like this :
local SavedPainting = {
Name = painting.Name,
ID = script.Value.Value,
Taken = true,
Date = pretty_date(os.date(“!*t”, now)),
Artist = player.Name
}
And i saved it with :
table.insert(toload, SavedPainting)
print(toload)
DataStore:SetAsync(“ArtIDSave”, game:GetService(“HttpService”):JSONEncode(toload))
And when i load it gives me that and i want it to load it as a table
To decode JSONEncode effected tables, use HttpService:JSONDecode() on the array.
Also the datastore is global Now what?
it gives me Can’t parse JSON error
Try running
print(typeof(data))
and if it doesn’t say “string” then use tostring(data) and then decode it
i tried
local array = “[{“Taken”:true,“Date”:“1/3/2021”,“Artist”:“SpecialTimeGaming”,“ID”:6185839475,“Name”:null}]”
local httpService = game:GetService(“HttpService”)
–local decodedTable = httpService:JSONDecode(array)
print(typeof(tostring(array)))
and it printed “string”
Oh wait give me a second i didnt understood you fully
i tried :
local array = "[{“Taken”:true,“Date”:“1/3/2021”,“Artist”:“SpecialTimeGaming”,“ID”:6185839475,“Name”:null}]"
local httpService = game:GetService("HttpService")
local something = typeof(tostring(array))
print(typeof(tostring(array)))
local decodedTable = httpService:JSONDecode(something)
and it printed “string”
then it gives me an error that said Can’t parse JSON
Try
local something = tostring(array)
instead, as at the moment ‘something’ will just equal “string” even though we want it to equal the JSON data
still Can’t parse JSON
Please help me!!!