@@ -62,9 +62,10 @@ cJSON * lua_fluid_json_dump_to_cJSON_object(LuaCEmbedTable *table){
6262
6363 }
6464 if (type == lua .types .BOOL ){
65- bool value = lua .tables .get_bool_by_index (table ,i );
65+ bool value = lua .tables .get_bool_by_index (table ,i );;
6666 cJSON_AddBoolToObject (created_object ,key , value );
6767 }
68+
6869 if (type == lua .types .TABLE ){
6970 LuaCEmbedTable * internal = lua .tables .get_sub_table_by_index (table ,i );
7071 cJSON * value = lua_fluid_json_dump_table_to_cJSON (internal );
@@ -78,6 +79,7 @@ cJSON * lua_fluid_json_dump_to_cJSON_object(LuaCEmbedTable *table){
7879cJSON * lua_fluid_json_dump_table_to_cJSON (LuaCEmbedTable * table ){
7980
8081 if (lua_json_fluid_table_is_object (table )){
82+
8183 return lua_fluid_json_dump_to_cJSON_object (table );
8284 }
8385 return lua_fluid_json_dump_to_cJSON_array (table );
@@ -117,9 +119,10 @@ LuaCEmbedResponse * lua_fluid_json_dump_to_string(LuaCEmbed *args){
117119
118120 bool ident = true;
119121
120- if (lua .args .get_type (args ,1 ) != lua .types .NOT_FOUND ){
122+ if (lua .args .get_type (args ,1 ) != lua .types .NILL ){
121123 ident = lua .args .get_bool (args ,1 );
122124 }
125+
123126 if (lua .has_errors (args )){
124127 char * error_msg = lua .get_error_message (args );
125128 return lua .response .send_error (error_msg );
@@ -135,28 +138,13 @@ LuaCEmbedResponse * lua_fluid_json_dump_to_string(LuaCEmbed *args){
135138
136139 LuaCEmbedResponse * response = lua .response .send_str (result_str );
137140 cJSON_Delete (result );
138-
139141 free (result_str );
140142 return response ;
141143}
142144
143145
144146LuaCEmbedResponse * lua_fluid_json_dump_to_file (LuaCEmbed * args ){
145147
146- char * output = lua .args .get_str (args ,1 );
147- if (lua .has_errors (args )){
148- char * error_msg = lua .get_error_message (args );
149- return lua .response .send_error (error_msg );
150- }
151- bool ident = true;
152-
153- if (lua .args .get_type (args ,2 ) != lua .types .NOT_FOUND ){
154- ident = lua .args .get_bool (args ,2 );
155- }
156- if (lua .has_errors (args )){
157- char * error_msg = lua .get_error_message (args );
158- return lua .response .send_error (error_msg );
159- }
160148
161149 cJSON * result = NULL ;
162150 int element_type = lua .args .get_type (args ,0 );
@@ -186,6 +174,25 @@ LuaCEmbedResponse * lua_fluid_json_dump_to_file(LuaCEmbed *args){
186174 );
187175 }
188176
177+
178+ char * output = lua .args .get_str (args ,1 );
179+ if (lua .has_errors (args )){
180+ char * error_msg = lua .get_error_message (args );
181+ cJSON_Delete (result );
182+ return lua .response .send_error (error_msg );
183+ }
184+ bool ident = true;
185+
186+ if (lua .args .get_type (args ,2 ) != lua .types .NILL ){
187+ ident = lua .args .get_bool (args ,2 );
188+ }
189+
190+ if (lua .has_errors (args )){
191+ char * error_msg = lua .get_error_message (args );
192+ cJSON_Delete (result );
193+ return lua .response .send_error (error_msg );
194+ }
195+
189196 char * result_str = NULL ;
190197 if (ident ){
191198 result_str = cJSON_Print (result );
0 commit comments