|
1 | 1 | #include "facebook_private.h" |
2 | 2 | #include "facebook_util.h" |
3 | 3 | #include <dmsdk/dlib/log.h> |
4 | | -#include <dmsdk/dlib/json.h> |
5 | 4 | #include <dmsdk/dlib/dstrings.h> |
6 | 5 | #include <dmsdk/script/script.h> |
7 | 6 |
|
@@ -567,18 +566,8 @@ size_t dmFacebook::CountStringArrayLength(lua_State* L, int table_index, size_t& |
567 | 566 |
|
568 | 567 | int dmFacebook::PushLuaTableFromJson(lua_State* L, const char* json) |
569 | 568 | { |
570 | | - char err_str[512] = {0}; |
571 | | - int err = 0; |
572 | | - dmJson::Document doc; |
573 | | - dmJson::Result r = dmJson::Parse(json, &doc); |
574 | | - if (r == dmJson::RESULT_OK && doc.m_NodeCount > 0) { |
575 | | - dmScript::JsonToLua(L, &doc, 0, err_str, sizeof(err_str)); |
576 | | - } else { |
577 | | - dmLogError("Failed to parse JSON (%d): %s", r, err_str); |
578 | | - err = 1; |
579 | | - } |
580 | | - dmJson::Free(&doc); |
581 | | - return err; |
| 569 | + dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails |
| 570 | + return 0; |
582 | 571 | } |
583 | 572 |
|
584 | 573 | void dmFacebook::RunStatusCallback(dmScript::LuaCallbackInfo* callback, const char* error, int status) |
@@ -621,25 +610,7 @@ void dmFacebook::RunJsonResultCallback(dmScript::LuaCallbackInfo* callback, cons |
621 | 610 | } |
622 | 611 | else |
623 | 612 | { |
624 | | - bool is_fail = false; |
625 | | - dmJson::Document doc; |
626 | | - dmJson::Result r = dmJson::Parse(json, &doc); |
627 | | - if (r == dmJson::RESULT_OK && doc.m_NodeCount > 0) { |
628 | | - char error_str_out[128]; |
629 | | - if (dmScript::JsonToLua(L, &doc, 0, error_str_out, sizeof(error_str_out)) < 0) { |
630 | | - dmLogError("Failed converting object JSON to Lua: %s", error_str_out); |
631 | | - is_fail = true; |
632 | | - } |
633 | | - } else { |
634 | | - dmLogError("Failed to parse JSON object(%d): (%s)", r, json); |
635 | | - is_fail = true; |
636 | | - } |
637 | | - dmJson::Free(&doc); |
638 | | - if (is_fail) { |
639 | | - lua_pop(L, 2); |
640 | | - dmScript::TeardownCallback(callback); |
641 | | - return; |
642 | | - } |
| 613 | + dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails |
643 | 614 | } |
644 | 615 |
|
645 | 616 | dmFacebook::PushError(L, error); |
|
0 commit comments