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: JSON Encoding/Decoding

Previous Thread :: Next Thread 
devMe is not online. devMe
Joined: 28 Jun 2014
Total Posts: 155
31 Mar 2015 03:36 AM
Im saving tables and have done so by encoding and decoding them.

I am using

local hs = game:GetService("HttpService")
local balloons = hs:JSONEncode(table)

But when I do that, I get an error: Can't parse JSON

What does that mean and what should I do?
Report Abuse
devMe is not online. devMe
Joined: 28 Jun 2014
Total Posts: 155
31 Mar 2015 05:23 AM
^
Report Abuse
SethDusek5 is not online. SethDusek5
Joined: 26 Mar 2011
Total Posts: 2580
31 Mar 2015 05:50 AM
Show us the table and the code for decoding it along with what you may recieve
Report Abuse
devMe is not online. devMe
Joined: 28 Jun 2014
Total Posts: 155
31 Mar 2015 05:54 AM
I just done some research and apparently if a table is empty, it gives you the error "Cant parse JSON"
Report Abuse
devMe is not online. devMe
Joined: 28 Jun 2014
Total Posts: 155
31 Mar 2015 06:03 AM
But it needs to load an empty table... any way around this?
Report Abuse
SethDusek5 is not online. SethDusek5
Joined: 26 Mar 2011
Total Posts: 2580
31 Mar 2015 07:02 AM
if str=="{}"
return {}
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
31 Mar 2015 08:15 AM
If the table is empty, don't save it. Example:

if next(Table) then -- "next" return the next value in the table, nil if there is none
-- Save table
end

When you load the table, check if it's nil, and if it is, replace it with an empty table:

local LoadedTable = (Table and hs:JSONDecode(Table)) or {}

~The herp lerped a derp~
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