Hi folks,
I'm having a problem with LuaJIT and Json
I get the next error and the project can't launch it:
Library/json.lua:325: Error reading 'null': {"data":{"sets": ...(more details)... ,[0,0,0],[0,0,
the print is incomplete so this shows me the system
This is a piece of code where the error occurs
function JsonReader:TestReservedWord(t) --line 322
for i, v in ipairs(t) do --line 323
if self:Next() ~= v then --line 324
error(string.format( --line 325
"Error reading '%s': %s", --line 326
table.concat(t), --line 327
self:All()))
end
end
end |
It was working well until the level is finished, and then used dataSaver.saveValue("sets", sets) for save scores, coins, and so.
I don't know if somebody have or had the same problem or if have some idea about this issue.
Any help thanks
P.S.
Without LuaJIT, Json worked fine in my project and saved all information.
Comments
I have not tried lua json with the luajit, been using native json available with Gideros and it all seems to run great
Unfortunately as lua json is not our lib, I doubt I can undestand the specific to fix it, would really recommend to move to native json
I just fix this some minutes before. I remembered your suggestion in this forum http://giderosmobile.com/forum/discussion/4673/luajit-and-tntparticlesengine#Item_6
So I did the next (this is only a little piece of my code)
1.-First step
save all proyect and exit gideros
3.- Third Step
restart machine and launch gideros
4.-
@ar2rsawseen with respect to a native LuaJit,I had no knowledge about it, if you were friendly you could tell me where I can get it and some link or example of how this works.
thanks again >-
P.S.
5.- Fifth Step
--sets = nil remove this line
[-] Liasoft
Likes: HubertRonald
[-] Liasoft
I read the reference manual and I tried to use the lines above provided by you, but I think it is not enough for me because I'm not understanding the mechanics of native Json well.
Other question I have is regarding the *. json How does it works? if I have the following file: worlds.json
Thanks again
[-] Liasoft
http://www.gamasutra.com/blogs/ArtursSosins/20131129/205956/Learning_Gideros_in_10_easy_steps.php
And Step 10 answered my first question (coins grow)
https://github.com/gideros/KitchenSink/blob/master/examples/Native_Json/Native_Json.lua
And I tried this but without successful :-/ :-/ :-/ :-/
Thanks again
[-] Liasoft
https://deluxepixel.com
As you have figured it out, you also need a mechanism to save and read the persistent data.
For that I have created a module dataSaver, which now uses native json:
https://github.com/ar2rsawseen/dataSaver
More on its usage:
http://appcodingeasy.com/Gideros-Mobile/Save-and-load-data-module-for-Gideros-Mobile
But basically, you need to note, that you can only save/write files in documents directory, so filenames should have |D| before them
Another view of where the information is stored, ie tables and if one can be edited with NotePad + + or TextWargler
Maybe at some point I saved "sets = nil" to clear all the information, but delimiting again I created the table "sets" and kept all the information and as I say this worked for me, and of course at that time used the json.lua
but I had not enabled luaJit
Thanks again
[-] Liasoft
Thanks for your answer I will take into account
[-] Liasoft
http://giderosmobile.com/forum/discussion/comment/20510#Comment_20510
Also can you try it this way:
Now I know that "sets" table is created with all its information.
I changed my code and update all classes
--[[ change: dataSaver.loadValue("|D|sets") by: dataSaver.load("|D|sets") change: dataSaver.saveValue("|D|sets") by: dataSaver.save("|D|sets") ]]
" the table "sets" is create, but the error does not occur when the app starts, but when to navigate the app, you execute an action that may lead to keep the same information twice for example, you play the level twice, you turn off the music for the second time, ie there is something going on and that did not happen when the luaJit was not used."
Any suggestion is welcome
[-] Liasoft
[-] Liasoft
I think why this is failing
While the native json does not show you where the error actually occurs within the model (this is critical for debugging) but unlike json.lua, you don't need delete myMath = dataSaver.load("|D|myMath") for re-run the model.
I will continue doing more testing and comment anything on this line
Finally, any suggestion is welcome
P.S
For more detail see
http://lua-users.org/wiki/InfAndNanComparisons
[-] Liasoft
But json.lua indicate in which variable is produced Nan or Inf (but not in which line of code)
However the native json no traces of like knowing that variable was NaN or Inf, it can be a headache when you are debugging.
My suggestion
-------------
if native json can't show you than variable is Inf or NaN, create your project with json.lua and when you are sure than variables aren't Inf or NaN and when you are ready for launch your application, you CHANGE json.lua for NATIVE.
Because it would be terrible or catastrophic :-t save the table is cut, then it would have to relaunch the application variables to zero, and this would generate a tremendous disappointment for users X( X( X( X( because they would lose their scores, so on.
[-] Liasoft
[-] Liasoft