mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
Some LUA work
This commit is contained in:
parent
feb677b7e8
commit
15645ab0bd
5 changed files with 62 additions and 11 deletions
27
src-core/common/lua/lua_utils.cpp
Normal file
27
src-core/common/lua/lua_utils.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "lua_utils.h"
|
||||
|
||||
namespace lua_utils
|
||||
{
|
||||
sol::table mapJsonToLua(sol::state &lua, nlohmann::json json)
|
||||
{
|
||||
sol::table l = lua.create_table();
|
||||
for (auto &el : json.items())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (el.value().is_number_integer())
|
||||
l[el.key()] = el.value().get<int>();
|
||||
else if (el.value().is_number())
|
||||
l[el.key()] = el.value().get<double>();
|
||||
else if (el.value().is_string())
|
||||
l[el.key()] = el.value().get<std::string>();
|
||||
else
|
||||
l[el.key()] = mapJsonToLua(lua, el.value());
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue