generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: JSONDecode issues

Previous Thread :: Next Thread 
OldGoldie is not online. 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 is not online. OldGoldie
Joined: 17 Aug 2010
Total Posts: 8210
30 Oct 2015 07:44 AM
b
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
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 is not online. 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
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image