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

Propositon to change JMap.objectWithTable implementation #79

Open
CarlosLeyvaAyala opened this issue Aug 29, 2021 · 2 comments
Open

Propositon to change JMap.objectWithTable implementation #79

CarlosLeyvaAyala opened this issue Aug 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@CarlosLeyvaAyala
Copy link

Hi.
I want to propose a change to the implementation of JMap.objectWithTable in jc.lua.

Current implementation only changes the Lua table at a superficial level, thus not converting nested Lua tables to JMap.

I did this and seems to work quite fine:

function JMap.objectWithTable(t)
  local object = JMap.object()
  for k,v in pairs(t) do
    if type(v) == "table" then
      object[k] = JMap.objectWithTable(v)
    else
      object[k] = v
    end
  end
  return object
end

Nothing too fancy, as you can see. Only a recursive call to deep converting the table.

@ryobg ryobg added the enhancement New feature or request label Nov 28, 2021
@ryobg
Copy link
Owner

ryobg commented Nov 28, 2021

Is this still a valid request? I'm reluctant to change existing functions behaviour. A new one might be better idea.

@CarlosLeyvaAyala
Copy link
Author

Yeah. It still is.

I used it quite A LOT in real "production" code and always worked reliably as expected.

Maybe a new function is a good idea, but still, I know the code works.

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

No branches or pull requests

2 participants