data printers BUGFIX handling print of no data (NULL tree)
diff --git a/src/printer_json.c b/src/printer_json.c
index d002da1..0f77615 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -858,6 +858,12 @@
     struct jsonpr_ctx ctx = {0};
     const char *delimiter = (options & LYD_PRINT_FORMAT) ? "\n" : "";
 
+    if (!root) {
+        ly_print_(out, "{}%s", delimiter);
+        ly_print_flush(out);
+        return LY_SUCCESS;
+    }
+
     ctx.out = out;
     ctx.level = 1;
     ctx.level_printed = 0;