Имеется структура
struct Color {
uint8_t background;
uint8_t foreground;
Color() :
backgroung(0), foreground(15)
{}
Color(const uint8_t& bg, const uint8_t& fg) :
background(bg), foreground(fg)
{}
}
И объект nlohmann::json _j
std::string obj =
"{ \"colors\": [ {\"background\": 0, \"foreground\": 1}, {\"background\": 0, \"foreground\": 4} ] }";
nlohmann::json _j = nlohmann::json::parse(obj);
Требуется в вектор :
std::vector<Color> vColors;
Поместить "colors" из объекта "_j"
int ba = _j ["background"].get<int>();