{"action":"created","issue":{"url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/10","repository_url":"https://api.github.com/repos/fengari-lua/fengari-interop","labels_url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/10/comments","events_url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/10/events","html_url":"https://github.com/fengari-lua/fengari-interop/issues/10","id":259634458,"number":10,"title":"Passing objects / arrays to Lua","user":{"login":"cristiano-belloni","id":315834,"avatar_url":"https://avatars2.githubusercontent.com/u/315834?v=4","gravatar_id":"","url":"https://api.github.com/users/cristiano-belloni","html_url":"https://github.com/cristiano-belloni","followers_url":"https://api.github.com/users/cristiano-belloni/followers","following_url":"https://api.github.com/users/cristiano-belloni/following{/other_user}","gists_url":"https://api.github.com/users/cristiano-belloni/gists{/gist_id}","starred_url":"https://api.github.com/users/cristiano-belloni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristiano-belloni/subscriptions","organizations_url":"https://api.github.com/users/cristiano-belloni/orgs","repos_url":"https://api.github.com/users/cristiano-belloni/repos","events_url":"https://api.github.com/users/cristiano-belloni/events{/privacy}","received_events_url":"https://api.github.com/users/cristiano-belloni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2017-09-21T21:13:19Z","updated_at":"2017-09-23T09:09:01Z","closed_at":null,"author_association":"NONE","body":"Hi, I tried to ask this on Freenet but I had to exit the client - hope it's not a problem if I ask here asynchronously. Maybe it can be useful to others, too.\r\n\r\nIs it possible to pass a Javascript array / object to lua with `fengari-interop` and have it converted into an equivalent Lua table? I'm trying something like [this gist](https://gist.github.com/cristiano-belloni/5a7a78062e2f986bd41045248c47c2f8).\r\nWhen I run it, the Lua interpreter says that the `type` of the passed array is `userdata`, but I can call `pairs` on it with no problems. If I try to get the length of it though (`#`), it excepts because it's not a table.\r\n\r\nIf it's not possible to do array/object => table automatically, what's my best option? Serializing by hand and pass via string?"},"comment":{"url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/comments/331621673","html_url":"https://github.com/fengari-lua/fengari-interop/issues/10#issuecomment-331621673","issue_url":"https://api.github.com/repos/fengari-lua/fengari-interop/issues/10","id":331621673,"user":{"login":"cristiano-belloni","id":315834,"avatar_url":"https://avatars2.githubusercontent.com/u/315834?v=4","gravatar_id":"","url":"https://api.github.com/users/cristiano-belloni","html_url":"https://github.com/cristiano-belloni","followers_url":"https://api.github.com/users/cristiano-belloni/followers","following_url":"https://api.github.com/users/cristiano-belloni/following{/other_user}","gists_url":"https://api.github.com/users/cristiano-belloni/gists{/gist_id}","starred_url":"https://api.github.com/users/cristiano-belloni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristiano-belloni/subscriptions","organizations_url":"https://api.github.com/users/cristiano-belloni/orgs","repos_url":"https://api.github.com/users/cristiano-belloni/repos","events_url":"https://api.github.com/users/cristiano-belloni/events{/privacy}","received_events_url":"https://api.github.com/users/cristiano-belloni/received_events","type":"User","site_admin":false},"created_at":"2017-09-23T09:09:01Z","updated_at":"2017-09-23T09:09:01Z","author_association":"NONE","body":"Ok, maybe - thinking about it - I see what you're suggesting: I can alwaws call `global.totable` from javascript if I do `js.global.totable = totable` after the Lua implementation of `totable`.\r\n\r\nSo it doesn't really matter if it's js-side or lua-side: it will still be a function, callable from js, that takes an object and returns a table. That makes sense, thanks."}}
{"actor":{"display_login":"cristiano-belloni"}}