identityref REVERT canonical value in JSON format with prefix

Do not use the standard JSON format as caonical
value and always print the prefix like before.

Refs #2090
diff --git a/src/plugins_types/identityref.c b/src/plugins_types/identityref.c
index e33b012..0a1fa32 100644
--- a/src/plugins_types/identityref.c
+++ b/src/plugins_types/identityref.c
@@ -1,9 +1,10 @@
 /**
  * @file identityref.c
  * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
  * @brief Built-in identityref type plugin.
  *
- * Copyright (c) 2019-2021 CESNET, z.s.p.o.
+ * Copyright (c) 2019-2023 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -277,9 +278,12 @@
             LY_CHECK_GOTO(ret, cleanup);
         }
     } else {
-        /* JSON format is the canonical one */
-        ret = identityref_ident2str(ident, LY_VALUE_JSON, ctx_node ? ctx_node->module : NULL, &canon, NULL);
-        LY_CHECK_GOTO(ret, cleanup);
+        /* JSON format with prefix is the canonical one */
+        if (asprintf(&canon, "%s:%s", ident->module->name, ident->name) == -1) {
+            LOGMEM(ctx);
+            ret = LY_EMEM;
+            goto cleanup;
+        }
 
         ret = lydict_insert_zc(ctx, canon, &storage->_canonical);
         LY_CHECK_GOTO(ret, cleanup);
@@ -315,7 +319,7 @@
 {
     char *ret;
 
-    if ((format == LY_VALUE_CANON) || (format == LY_VALUE_JSON) || (format == LY_VALUE_LYB)) {
+    if (format == LY_VALUE_CANON) {
         if (dynamic) {
             *dynamic = 0;
         }
diff --git a/tests/utests/types/identityref.c b/tests/utests/types/identityref.c
index b69299e..107164d 100644
--- a/tests/utests/types/identityref.c
+++ b/tests/utests/types/identityref.c
@@ -81,7 +81,7 @@
     /* local ident, XML/JSON print */
     data = "<l1 xmlns=\"urn:tests:defs\">ident1</l1>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, tree);
-    CHECK_LYD_NODE_TERM((struct lyd_node_term *)tree, 0, 0, 0, 0, 1, IDENT, "ident1", "ident1");
+    CHECK_LYD_NODE_TERM((struct lyd_node_term *)tree, 0, 0, 0, 0, 1, IDENT, "defs:ident1", "ident1");
     CHECK_LYD_STRING_PARAM(tree, data, LYD_XML, LYD_PRINT_SHRINK);
     CHECK_LYD_STRING_PARAM(tree, "{\"defs:l1\":\"ident1\"}", LYD_JSON, LYD_PRINT_SHRINK);
     lyd_free_all(tree);
diff --git a/tests/utests/types/instanceid.c b/tests/utests/types/instanceid.c
index efc2b44..4174e4d 100644
--- a/tests/utests/types/instanceid.c
+++ b/tests/utests/types/instanceid.c
@@ -125,7 +125,7 @@
             "<list-ident xmlns=\"urn:tests:defs\"><id xmlns:b=\"urn:tests:defs\">b:ident-der2</id>"
             "<value>y</value></list-ident>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "a:l1", "/a:list-ident[a:id='a:ident-der1']/a:value",
-            INST, "/defs:list-ident[id='ident-der1']/value", val5);
+            INST, "/defs:list-ident[id='defs:ident-der1']/value", val5);
 
     TEST_SUCCESS_XML2("<list2 xmlns=\"urn:tests:defs\"><id>defs:xxx</id><id2>x</id2></list2>"
             "<list2 xmlns=\"urn:tests:defs\"><id>a:xxx</id><id2>y</id2></list2>",
diff --git a/tests/utests/types/union.c b/tests/utests/types/union.c
index 6a8b3df..d23cbf1 100644
--- a/tests/utests/types/union.c
+++ b/tests/utests/types/union.c
@@ -86,7 +86,7 @@
             "defs", "", "un1", "2", UNION, "2", STRING, "2");
 
     TEST_SUCCESS_XML2("<int8 xmlns=\"urn:tests:defs\">10</int8>",
-            "defs", "xmlns:x=\"urn:tests:defs\"", "un1", "x:ident2", UNION, "ident2", IDENT, "ident2", "ident2");
+            "defs", "xmlns:x=\"urn:tests:defs\"", "un1", "x:ident2", UNION, "defs:ident2", IDENT, "defs:ident2", "ident2");
 
     TEST_SUCCESS_XML2("<int8 xmlns=\"urn:tests:defs\">10</int8>",
             "defs", "xmlns:x=\"urn:tests:defs\"", "un1", "x:ident55", UNION, "x:ident55", STRING, "x:ident55");