Key

Inform the config filler that this sequence is to be read as a mapping

On some occasions, one might want to read a mapping as an array. One reason to do so may be to provide a better experience to the user, e.g. having to type:

interfaces:
  eth0:
    ip: "192.168.0.1"
    private: true
  wlan0:
    ip: "1.2.3.4"

Instead of the slightly more verbose:

interfaces:
  - name: eth0
    ip: "192.168.0.1"
    private: true
  - name: wlan0
    ip: "1.2.3.4"

The former would require to be expressed as an associative arrays. However, one major drawback of associative arrays is that they can't have an initializer, which makes them cumbersome to use in the context of the config filler. To remediate this issue, one may use @Key("name") on a field (here, interfaces) so that the mapping is flattened to an array. If name is null, the key will be discarded.

struct Key {}

Members

Variables

name
string name;

Meta