@@ -943,13 +943,7 @@ lydjson_parse_opaq(struct lyd_json_ctx *lydctx, const char *name, size_t name_le
943943 ret = lydjson_create_opaq (lydctx , name , name_len , prefix , prefix_len , parent , status_inner_p , node_p );
944944 LY_CHECK_RET (ret );
945945
946- if ((* status_p == LYJSON_OBJECT ) || (* status_p == LYJSON_OBJECT_EMPTY )) {
947- /* process children */
948- while (* status_p != LYJSON_OBJECT_CLOSED && * status_p != LYJSON_OBJECT_EMPTY ) {
949- LY_CHECK_RET (lydjson_subtree_r (lydctx , * node_p , lyd_node_child_p (* node_p ), NULL ));
950- * status_p = lyjson_ctx_status (lydctx -> jsonctx , 0 );
951- }
952- } else if ((* status_p == LYJSON_ARRAY ) || (* status_p == LYJSON_ARRAY_EMPTY )) {
946+ while ((* status_p == LYJSON_ARRAY ) || (* status_p == LYJSON_ARRAY_EMPTY )) {
953947 /* process another instance of the same node */
954948 /* but first mark the node to be expected a list or a leaf-list */
955949 ((struct lyd_node_opaq * )* node_p )-> hints |= LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST ;
@@ -963,16 +957,26 @@ lydjson_parse_opaq(struct lyd_json_ctx *lydctx, const char *name, size_t name_le
963957 }
964958
965959 LY_CHECK_RET (lyjson_ctx_next (lydctx -> jsonctx , status_inner_p ));
960+ if (* status_inner_p == LYJSON_ARRAY_CLOSED ) {
961+ goto finish ;
962+ }
966963
967964 /* continue with the next instance */
968- if (* status_inner_p != LYJSON_ARRAY_CLOSED ) {
969- assert (node_p );
970- lydjson_maintain_children (parent , first_p , node_p );
971- return lydjson_parse_opaq (lydctx , name , name_len , prefix , prefix_len , parent , status_p , status_inner_p ,
972- first_p , node_p );
965+ assert (node_p );
966+ lydjson_maintain_children (parent , first_p , node_p );
967+ ret = lydjson_create_opaq (lydctx , name , name_len , prefix , prefix_len , parent , status_inner_p , node_p );
968+ LY_CHECK_RET (ret );
969+ }
970+
971+ if ((* status_p == LYJSON_OBJECT ) || (* status_p == LYJSON_OBJECT_EMPTY )) {
972+ /* process children */
973+ while (* status_p != LYJSON_OBJECT_CLOSED && * status_p != LYJSON_OBJECT_EMPTY ) {
974+ LY_CHECK_RET (lydjson_subtree_r (lydctx , * node_p , lyd_node_child_p (* node_p ), NULL ));
975+ * status_p = lyjson_ctx_status (lydctx -> jsonctx , 0 );
973976 }
974977 }
975978
979+ finish :
976980 /* finish linking metadata */
977981 LY_CHECK_RET (lydjson_metadata_finish (lydctx , lyd_node_child_p (* node_p )));
978982
0 commit comments