parser json UPDATE optional JSON 'null' value parsed and ignored (#2216)

This patch introduces parsing flag, which allows user to use JSON 'null'
value with leaf, leaf-list and anydata
diff --git a/src/parser_data.h b/src/parser_data.h
index d13fd57..9d79556 100644
--- a/src/parser_data.h
+++ b/src/parser_data.h
@@ -176,6 +176,8 @@
                                                  be checked (length, range, pattern, ...) and if a value can be stored,
                                                  it is. Calling separate validation on these data always checks all the
                                                  restrictions as well. */
+#define LYD_PARSE_JSON_NULL 0x4000000       /**< Allow using JSON empty value 'null' within JSON input. By default such value
+                                                 is not supported and according to RFC 7951 '[null]' shall be used instead. */
 
 #define LYD_PARSE_OPTS_MASK 0xFFFF0000      /**< Mask for all the LYD_PARSE_ options. */
 
diff --git a/src/parser_json.c b/src/parser_json.c
index 95d689a..6facc07 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1492,7 +1492,10 @@
     if (r == LY_SUCCESS) {
         assert(snode->nodetype & (LYD_NODE_TERM | LYD_NODE_INNER | LYD_NODE_ANY));
         if (snode->nodetype & LYD_NODE_TERM) {
-            if ((*status != LYJSON_ARRAY) && (*status != LYJSON_NUMBER) && (*status != LYJSON_STRING) &&
+            if ((lydctx->parse_opts & LYD_PARSE_JSON_NULL) && (*status == LYJSON_NULL)) {
+                /* do not do anything if value is JSON 'null' */
+                goto cleanup;
+            } else if ((*status != LYJSON_ARRAY) && (*status != LYJSON_NUMBER) && (*status != LYJSON_STRING) &&
                     (*status != LYJSON_FALSE) && (*status != LYJSON_TRUE) && (*status != LYJSON_NULL)) {
                 rc = LY_ENOT;
                 goto cleanup;
@@ -1519,6 +1522,10 @@
             r = lydjson_parse_instance_inner(lydctx, snode, ext, status, node);
             LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
         } else {
+            if ((lydctx->parse_opts & LYD_PARSE_JSON_NULL) && (*status == LYJSON_NULL)) {
+                /* do not do anything if value is JSON 'null' */
+                goto cleanup;
+            }
             /* create any node */
             r = lydjson_parse_any(lydctx, snode, ext, status, node);
             LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);