Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert LUA Table to javascript object #49

Open
stackola opened this issue Mar 20, 2019 · 0 comments
Open

How to convert LUA Table to javascript object #49

stackola opened this issue Mar 20, 2019 · 0 comments

Comments

@stackola
Copy link

stackola commented Mar 20, 2019

My question is basically in the title.

Is there a way to convert a table passed in from LUA to native JS?

{key:value} objects seem to work alright, but [value, value, value] arrays do not.

Here's an example:

Lua:

{obj = {key = "value"},  str = "string", arr = {1,2,3} }

Calling an environment function..

JS:

{
  "obj": {
    "__shine": {
      "type": "table",
      "index": 55,
      "keys": [],
      "values": [],
      "numValues": [
        null
      ],
      "refCount": 1
    },
    "key": "value"
  },
  "str": "string",
  "arr": {
    "__shine": {
      "type": "table",
      "index": 56,
      "keys": [],
      "values": [],
      "numValues": [
        null,
        1,
        2,
        3
      ],
      "refCount": 2
    }
  }
}

What I wanted:

{
  "obj": {
    "key": "value"
  },
  "str": "string",
  "arr": [
    1,
    2,
    3
  ]
}

This would obviously need to be done in a recursive manner.

Does a functionality like this exist already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant