![]() |
libyang
1.0.101
YANG data modeling language library
|
Data parser allows to read instances from a specific format. libyang supports the following data formats:
XML
Original data format used in NETCONF protocol. XML mapping is part of the YANG specification (RFC 6020).
JSON
The alternative data format available in RESTCONF protocol. Specification of JSON encoding of data modeled by YANG can be found in RFC 7951.
Besides the format of input data, the parser functions accepts additional options to specify how the input data should be processed.
In contrast to the schema parser, data parser also accepts empty input data if such an empty data tree is valid according to the schemas in the libyang context.
If a node from a schema, which is not present in the context or is not implemented, is parsed, a callback set by ly_ctx_set_module_data_clb() is called and this way the application is given the opportunity to add this schema into the context or change its conformance before the parsing would fail.
In case of XML input data, there is one additional way to parse input data. Besides parsing the data from a string in memory or a file, caller is able to build an XML tree using libyang XML parser and then use this tree (or a part of it) as input to the lyd_parse_xml() function.