[Resolved] json encode bug on device

Hi,

I’m getting this error when running some json code on a iPhone or iPad:

Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to call field ‘encode’ (a nil value)

It doesn’t happen on the simulator. I’m basically following the code here:

http://developer.anscamobile.com/reference/index/jsonencode

Any ideas what might be the problem?

thanks! [import]uid: 43692 topic_id: 24793 reply_id: 324793[/import]

What Corona build are you using ?

I´m using the latest daily build and the correct code for it to run is:

local t = { ["name1"] = "value1", ["name2"] = {1, false, true, 23.54, "a \021 string"}, name3 = json.null -- before it was json.null() } [import]uid: 10141 topic_id: 24793 reply_id: 100544[/import]

It sounds like you are writing over the json variable after you do:

local json = require(“json”)

or you are not doing that line at all.

[import]uid: 19626 topic_id: 24793 reply_id: 100549[/import]

Turns out this was a strange user error - I still had a json library in my project (from before it was in core Corona), which has methods with a different case (Encode v encode I think). Anyway this was working OK on the simulator but not on device. Removing the library has solved it.

Thanks for the posts! [import]uid: 43692 topic_id: 24793 reply_id: 100553[/import]