parser json BUGFIX swapping recursion with a cycle

The change prevents stack-overflow error.
diff --git a/src/parser_json.c b/src/parser_json.c
index e6ef947..7beffed 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -943,13 +943,7 @@
     ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p);
     LY_CHECK_RET(ret);
 
-    if ((*status_p == LYJSON_OBJECT) || (*status_p == LYJSON_OBJECT_EMPTY)) {
-        /* process children */
-        while (*status_p != LYJSON_OBJECT_CLOSED && *status_p != LYJSON_OBJECT_EMPTY) {
-            LY_CHECK_RET(lydjson_subtree_r(lydctx, *node_p, lyd_node_child_p(*node_p), NULL));
-            *status_p = lyjson_ctx_status(lydctx->jsonctx, 0);
-        }
-    } else if ((*status_p == LYJSON_ARRAY) || (*status_p == LYJSON_ARRAY_EMPTY)) {
+    while ((*status_p == LYJSON_ARRAY) || (*status_p == LYJSON_ARRAY_EMPTY)) {
         /* process another instance of the same node */
         /* but first mark the node to be expected a list or a leaf-list */
         ((struct lyd_node_opaq *)*node_p)->hints |= LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST;
@@ -963,16 +957,26 @@
         }
 
         LY_CHECK_RET(lyjson_ctx_next(lydctx->jsonctx, status_inner_p));
+        if (*status_inner_p == LYJSON_ARRAY_CLOSED) {
+            goto finish;
+        }
 
         /* continue with the next instance */
-        if (*status_inner_p != LYJSON_ARRAY_CLOSED) {
-            assert(node_p);
-            lydjson_maintain_children(parent, first_p, node_p);
-            return lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_p, status_inner_p,
-                    first_p, node_p);
+        assert(node_p);
+        lydjson_maintain_children(parent, first_p, node_p);
+        ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p);
+        LY_CHECK_RET(ret);
+    }
+
+    if ((*status_p == LYJSON_OBJECT) || (*status_p == LYJSON_OBJECT_EMPTY)) {
+        /* process children */
+        while (*status_p != LYJSON_OBJECT_CLOSED && *status_p != LYJSON_OBJECT_EMPTY) {
+            LY_CHECK_RET(lydjson_subtree_r(lydctx, *node_p, lyd_node_child_p(*node_p), NULL));
+            *status_p = lyjson_ctx_status(lydctx->jsonctx, 0);
         }
     }
 
+finish:
     /* finish linking metadata */
     LY_CHECK_RET(lydjson_metadata_finish(lydctx, lyd_node_child_p(*node_p)));