lyd_parse_data_mem ignore subsequent data after a data without matching schema node definition, is this the expectation?
module
module xxx-ifm {
namespace "urn:xxx:yang:xxx-ifm";
prefix ifm;
container ifm {
.....
}
}
module xxx-aaa{
namespace "urn:xxx:yang:xxx-aaa";
prefix aaa;
container aaa {
.....
}
}
rpc_message_1:
"{\"huawei-ifm:ifm\":{},\"xxx:inexisted\":{\"tcp-global\":{\"tcp-max-mss\":1460}},\"huawei-aaa:aaa\":{}}"
rpc_message_2:
"{\"xxx:inexisted\":{\"tcp-global\":{\"tcp-max-mss\":1460}},\"huawei-ifm:ifm\":{}}"
In which xxx:inexisted is a data that cannot match a schema.
when I call lyd_parse_data_mem:
LY_ERR err = lyd_parse_data_mem(ly_ctx, <rpc_message_n>, LYD_JSON, LYD_PARSE_WHEN_TRUE | LYD_PARSE_NO_STATE | LYD_PARSE_ONLY, 0, &ly_data);
for rpc_message_1, the ly_data only contain ifm and not contain inexisted and aaa,
for rpc_message_2, the ly_data is null pointer.
It seems that libyang once encounter a data that cannot match schema, libyang will drop the remaing data. Is this the expection when design ?
version 2.1.30
thanks
Is this the expection when design ?
Yes, if LYD_PARSE_STRICT is not used when parsing the data.
Fine...I though it would just ignore the mere data that cannot match schema and would go to parse the remain data 🤣
I should start reading the issues more carefully, I have not understood what is the actual problem you are having, sorry. In any case, I have tried your use-cases and it worked for me as expected meaning only the unknown node with all the descendants was ignored and all the known containers parsed normally.
For example,
"{\"huawei-ifm:ifm\":{},\"xxx:inexisted\":{\"tcp-global\":{\"tcp-max-mss\":1460}},\"huawei-aaa:aaa\":{}}"
there is three top node, ifm, inexisted and aaa.
When the parser process inexisted, because it has no schema matched, and it is ignored, and I think it is ok.
But the next sibling aaa will be ignore too, I think the parser should not ignore the remaining siblings.
Please provide the exact YANG modules and data to reproduce, it worked fine for me with your JSON data and small modules I have written based on them, only the non-existing node has been skipped.