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
|
  |
| Joined: 28 Jun 2014 |
| Total Posts: 155 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|