libyang  3.6.1
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Printing Data

Data printers allows to serialize internal representation of a data tree in a specific format. libyang supports the following data formats for printing:

  • XML

    Basic format as specified in rules of mapping YANG modeled data to XML in 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.

By default, both formats are printed with indentation (formatting), which can be avoided by LYD_PRINT_SHRINK printer option). Other options adjust e.g. with-defaults mode.

Besides the legacy functions from libyang 1.x (lyd_print_clb(), lyd_print_fd(), lyd_print_file(), lyd_print_mem() and lyd_print_path()) printing data into the specified output, there are also new functions using output handler introduced in libyang 2.0. In contrast to schema printers, there is no limit of the functionality and the functions can be used interchangeable. The only think to note is that the new functions lyd_print_all() and lyd_print_tree() does not accept LYD_PRINT_WITHSIBLINGS printer option) since this flag differentiate the functions themselves.

Functions List