path::CodecService

class ydk::path::CodecService

Codec Service, part of YDK path API, which deals with generic path-based YANG data nodes

virtual std::string encode(const std::unique_ptr<DataNode> datanode, EncodingFormat format, bool pretty)

Encode the given DataNode Tree

Parameters:
  • datanode – The DataNode to encode
  • format – format to encode to, either JSON or XML
  • pretty – The output is indented for human consumption if pretty is true
Returns:

The encoded string

Raises:

YCPPInvalidArgumentError if the arguments are invalid

virtual std::unique_ptr<DataNode> decode(const RootSchemaNode &root_schema, const std::string &buffer, Format format)

Decode the buffer to return a DataNode

Parameters:
  • root_schema – The root schema to use
  • buffer – The string representation of the DataNode
  • format – Decode format
Returns:

The DataNode instantiated or nullptr in case of error.

Raises:

YCPPInvalidArgumentError if the arguments are invalid.

virtual ~CodecService()