1

Refering to this question yaml-cpp read sequence in item

If the yaml looks like

sensors:
  - id1:
      hardwareId: 28-000005a32133
      type: 1
  - id2:
      hardwareId: 28-000005a32132
      type: 4

How to get the name of the sequence from the node ? Using the sensors node how can i get the names of id1 and id2 ?

suri435
  • 11
  • 2

1 Answers1

2

Just iterate through the node; you get key/value pairs:

for (const auto& kv : node["sensors"]) {
  kv.first.as<std::string>();  // "id1" or "id2"
}
Jesse Beder
  • 33,081
  • 21
  • 109
  • 146