Representing gNMI Paths as Strings

robjs, aashaikh, csl, hines.

October 2018


This document provides a specification for the representation of a gNMI
message as a string. String encoding MUST NOT be used within the protocol, but
provides means to simplify human interaction with gNMI paths - for example, in
device or daemon configuration.

String Representation of a Single Element

A gNMI path consists of a series of PathElem messages. These messages
consist of a name and a map of keys. Each PathElem is represented as a
string in the form:


Where name is the PathElem name field, key1 represents a key of the
keys map, and val1 represents the value corresponding to key1 within the
map. Where multiple keys are present (as shown with key1 and key2) the
values are encoded in the form:


and appended to the string. If the key value contains a ] character, it is
escaped by preceding it with the backslash (\) character. Only ] and \
characters must be escaped. Newlines and carriage returns are encoded as \n
and \r respectively. Unicode characters are encoded as \u1234 or \U1234.

If multiple keys exist for a particular element, they MUST be specified sorted
alphabetically by the key name.

String Representation of an Entire Path

Using the format for each PathElem described above, the entire path is formed
by concatenating the series of strings with a / character between each
PathElem. If the path is absolute (i.e., starts at the schema root), it is
preceded by a / character. The prefix + path expressed in gNMI is always

Stringified Path Examples

A reference implementation of path to string encoding, and string to path can
be found in ygot’s