parser json BUGFIX lydctx may be NULL on error
diff --git a/src/parser_json.c b/src/parser_json.c
index 4eca7d7..66e58ed 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1578,7 +1578,7 @@
 
 cleanup:
     /* there should be no unresolved types stored */
-    assert(!(parse_opts & LYD_PARSE_ONLY) || (!lydctx->node_types.count && !lydctx->meta_types.count &&
+    assert(!(parse_opts & LYD_PARSE_ONLY) || !lydctx || (!lydctx->node_types.count && !lydctx->meta_types.count &&
             !lydctx->node_when.count));
 
     if (rc) {