parser json BUGFIX check for parameter validity

Fixes #2246
diff --git a/src/parser_json.c b/src/parser_json.c
index 55f0ed9..4a94d03 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1193,7 +1193,7 @@
     /* parse as an attribute to a (opaque) node */
     if (!attr_node) {
         /* try to find the instance */
-        LY_LIST_FOR(*first_p, attr_node) {
+        LY_LIST_FOR(parent ? lyd_child(parent) : *first_p, attr_node) {
             if (snode) {
                 if (attr_node->schema) {
                     if (attr_node->schema == snode) {