libyang  1.0.184
YANG data modeling language library
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. It is possible to specify if the indentation (formatting) will be used (by LYP_FORMAT printer option).

  • JSON

    The alternative data format available in RESTCONF protocol. Specification of JSON encoding of data modeled by YANG can be found in this draft.It is possible to specify if the indentation (formatting) will be used (by LYP_FORMAT printer option).

Printer functions allow to print to the different outputs including a callback function which allows caller to have a full control of the output data - libyang passes to the callback a private argument (some internal data provided by a caller of lyd_print_clb()), string buffer and number of characters to print. Note that the callback is supposed to be called multiple times during the lyd_print_clb() execution.

To print the data tree with default nodes according to the with-defaults capability defined in RFC 6243, check the page about the default values.

Also, to print the data in NETCONF format, use the LYP_NETCONF flag. More information can be found on the page Data Instances.

Functions List

  • lyd_print_mem()
  • lyd_print_fd()
  • lyd_print_file()
  • lyd_print_clb()