fix null obj is not translated to a json null literal in dbuObjectToJson2

Wed, 25 Mar 2026 20:07:38 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 25 Mar 2026 20:07:38 +0100
changeset 53
82adacc27b5b
parent 52
8503be5eea49
child 54
eb4054841cd6

fix null obj is not translated to a json null literal in dbuObjectToJson2

dbutils/json.c file | annotate | diff | comparison | revisions
dbutils/object.c file | annotate | diff | comparison | revisions
test/json.c file | annotate | diff | comparison | revisions
--- a/dbutils/json.c	Wed Feb 04 20:00:54 2026 +0100
+++ b/dbutils/json.c	Wed Mar 25 20:07:38 2026 +0100
@@ -85,7 +85,7 @@
             } else if(field->toObject) {
                 DBUObject child_obj = field->toObject(field, obj);
                 if(child_obj == NULL) {
-                    child = CX_JSON_NULL;
+                    child = cxJsonCreateLiteral(a, CX_JSON_NULL);
                 } else if(field->objType) {
                     child = dbuObjectToJson2(field->objType, child_obj, a, setNull, forceString);
                 }
--- a/dbutils/object.c	Wed Feb 04 20:00:54 2026 +0100
+++ b/dbutils/object.c	Wed Mar 25 20:07:38 2026 +0100
@@ -153,7 +153,7 @@
 }
 
 int dbuObjectBuilderGetArray(DBUObjectBuilder *builder, void **array, size_t *size) {
-    
+    return 1;
 }
 
 void dbuObjectBuilderDestroy(DBUObjectBuilder *builder) {
--- a/test/json.c	Wed Feb 04 20:00:54 2026 +0100
+++ b/test/json.c	Wed Mar 25 20:07:38 2026 +0100
@@ -110,6 +110,8 @@
     test5_class = dbuRegisterClassWithoutPK(ctx, "test5", sizeof(Test5));
     dbuClassAdd(test5_class, Test5, test);
     dbuClassAddCxLinkedList(test5_class, "test2List", offsetof(Test5, test2List), test2_class);
+    
+    return 0;
 }
 
 void cleanup_json_tests(void) {

mercurial