OldGoldie
|
  |
| Joined: 17 Aug 2010 |
| Total Posts: 8210 |
|
|
| 30 Oct 2015 03:23 AM |
It encodes fine. But it will not decode correctly, it will just decode into nil I am using a datastore to store tables that are JSONed. But when I decode it everything is nil. This is what it prints: table: 0AFF80D0 nil
and the table saved is: [null,"Sword","500",1,23532823]
http = game:GetService('HttpService') ds = game:GetService("DataStoreService"):GetDataStore("shop") list = ds:GetAsync("shop")
for i = 1,#list do print(list[i]) local j = http:JSONDecode(list[i]) print(j[2]) --game.ReplicatedStorage.GUIClient:InvokeClient(player, j) wait() end
|
|
|
| Report Abuse |
|
|
OldGoldie
|
  |
| Joined: 17 Aug 2010 |
| Total Posts: 8210 |
|
| |
|
|
| 30 Oct 2015 08:08 AM |
It already prints a table address, so: I'm guessing you're saving the table without using JSONEncode? If so, you don't need to use JSONDecode. It will be done automatically for you. |
|
|
| Report Abuse |
|
|
OldGoldie
|
  |
| Joined: 17 Aug 2010 |
| Total Posts: 8210 |
|
|
| 31 Oct 2015 02:39 PM |
I do save it, but when I decode it and try print
j[2] (the decoded table)
I get nil |
|
|
| Report Abuse |
|
|
|
| 31 Oct 2015 03:03 PM |
You're using JSONDecode on a table. Unless you're using JSONDecode on a string, it will return nil. In this case, you don't need to use it. |
|
|
| Report Abuse |
|
|