printer json BUGFIX close array only if opened

Fixes cesnet/netopeer2#1093
diff --git a/src/printer_json.c b/src/printer_json.c
index dc57719..6b2ee02 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -669,12 +669,17 @@
 static ly_bool
 json_print_array_is_last_inst(struct jsonpr_ctx *ctx, const struct lyd_node *node)
 {
+    if (!is_open_array(ctx, node)) {
+        /* no array open */
+        return 0;
+    }
+
     if ((ctx->root == node) && !(ctx->options & LYD_PRINT_WITHSIBLINGS)) {
         /* the only printed instance */
         return 1;
     }
 
-    if (is_open_array(ctx, node) && (!node->next || (node->next->schema != node->schema))) {
+    if (!node->next || (node->next->schema != node->schema)) {
         /* last instance */
         return 1;
     }