Corona Simulator Bug regarding json.lua

I have been finding a strange behavior:

In the Corona Simulator, all was running normally, and I could retrieve my data normally from my server.

However, while running on iOS simulator or devices, i got a print in the Xcode organizer console “attempt to index global json…” which is only when I finally understand that in my source code, I forgot to include the “local json = require(“json”)” line (which I realized only after 3 hours I just spent debugging my app)

Nevertheless, how come the json object was working in the corona sim, and not in iOS env if I did not include this external library in my code ? Is the json file now part of the corona SDK ? If so, how come it did not export it along with rest of the code ?

THanks for any feedback on this, cause I did spend quite a long time trying to figure this out… [import]uid: 23043 topic_id: 12396 reply_id: 312396[/import]

Sorry, i forgot to mention my corona build: Version 2011.564 (2011.4.12) [import]uid: 23043 topic_id: 12396 reply_id: 45170[/import]

Hi
I included the library and the file for lua 5.1 by Shaun Brown and it is working great but I am sure I have read that the json library somehow has been incorporated in the core but I haven’t tried removing the require line just yet.

Make sure you include the json.lua file and test again otherwise I can suspect that there is something regarding case sensitivity in the code in the incorporated library maybe. I had to change some of the functions in the lua file by Shaun Brown to json instead of Json to make encode and decode work this way. [import]uid: 22737 topic_id: 12396 reply_id: 45178[/import]

Hi, thanks for your reply.

CONCLUSION for anyone experiencing this issue. Just include the instruction local json = require(“json”) in your code, because as of the corona SDK version build mentionned (or even prior), it will run fine in the Corona Simulator without it, but it won’t work in either the iOS simulator, nor any iOS device. In other words, wIthout including the file explicitly in your code, your app will not be able to parse the json coming from the server response if not running in the Corona Simulator. [import]uid: 23043 topic_id: 12396 reply_id: 45186[/import]