printer json BUGFIX nested union value print

Fix an infinite loop in json_print_value() when
resolved type of a union member is also union.

Fixes: 183b911ec920 ("printer json BUGFIX union realtype value print")

Signed-off-by: Ilyes Ben Hamouda <ilyes.ben_hamouda@6wind.com>
diff --git a/src/printer_json.c b/src/printer_json.c
index 165dfab..312e30d 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -363,7 +363,8 @@
     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: