Skip to content

Commit

Permalink
Merge pull request #43 from defold/lua-to-json
Browse files Browse the repository at this point in the history
Updated to use dmScript::LuaToJson()
  • Loading branch information
JCash committed Nov 2, 2022
2 parents 1fd2ce2 + 0f00949 commit c94562d
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions gpgs/src/gpgs_callback.cpp
Expand Up @@ -60,26 +60,7 @@ static void gpgs_invoke_callback(MESSAGE_ID type, const char* json)
}
else {
lua_pushnumber(L, type);
int count_table_elements = 1;
bool is_fail = false;
dmJson::Document doc;
dmJson::Result r = dmJson::Parse(json, &doc);
if (r == dmJson::RESULT_OK && doc.m_NodeCount > 0) {
char error_str_out[128];
if (dmScript::JsonToLua(L, &doc, 0, error_str_out, sizeof(error_str_out)) < 0) {
dmLogError("Failed converting object JSON to Lua; %s", error_str_out);
is_fail = true;
}
} else {
dmLogError("Failed to parse JSON object(%d): (%s)", r, json);
is_fail = true;
}
dmJson::Free(&doc);
if (is_fail) {
lua_pop(L, 2);
assert(top == lua_gettop(L));
return;
}
dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails

int number_of_arguments = 3;
int ret = lua_pcall(L, number_of_arguments, 0, 0);
Expand Down

0 comments on commit c94562d

Please sign in to comment.