data tree CHANGE modify lyd_leaf_type()
change the function to return not only the data type enumeration but
the complete data type definition. This allows caller to get detailed
information about the type restrictions.
Relates to CESNET/Netopeer2#47
diff --git a/src/printer_json.c b/src/printer_json.c
index 01c87d0..aa6498f 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -90,6 +90,7 @@
const char *schema = NULL;
const struct lys_module *wdmod = NULL;
LY_DATA_TYPE datatype;
+ const struct lys_type *type;
if ((node->dflt && (options & (LYP_WD_ALL_TAG | LYP_WD_IMPL_TAG))) ||
(!node->dflt && (options & LYP_WD_ALL_TAG) && lyd_wd_default(leaf))) {
@@ -134,7 +135,13 @@
break;
case LY_TYPE_LEAFREF:
- datatype = lyd_leaf_type(leaf);
+ type = lyd_leaf_type(leaf);
+ if (!type) {
+ /* error */
+ ly_print(out, "\"(!error!)\"");
+ break;
+ }
+ datatype = type->base;
goto contentprint;
case LY_TYPE_EMPTY: