diff --git a/src/printer_json.c b/src/printer_json.c index 165dfab5d..312e30df1 100644 --- a/src/printer_json.c +++ b/src/printer_json.c @@ -363,7 +363,8 @@ json_print_value(struct jsonpr_ctx *pctx, const struct ly_ctx *ctx, const struct switch (basetype) { case LY_TYPE_UNION: /* use the resolved type */ - basetype = val->subvalue->value.realtype->basetype; + val = &val->subvalue->value; + basetype = val->realtype->basetype; goto print_val; case LY_TYPE_BINARY: