-
Hello everyone, a question has arisen, how can I fill in json using a loop? The parameter below overwrites the last object instead of adding a new one (ini.getValue is just a string to read) for (auto row = sections.begin(); row != sections.end(); ++row)
{
std::string defId = row->pItem;
const char* defIdChar = defId.c_str();
printf("value = '%s'\n", defIdChar);
dataResult["data"] =
{
{
defIdChar,
{
{"id",ini.GetValue(defIdChar, "id", "noone")},
{"uid",ini.GetValue(defIdChar, "uid", "noone")},
{"category",ini.GetValue(defIdChar, "category", "noone")},
{"name",ini.GetValue(defIdChar, "name", "noone")},
{"content",ini.GetValue(defIdChar, "content", "noone")},
{"price",ini.GetValue(defIdChar, "price", "noone")},
{"parent",ini.GetValue(defIdChar, "parent", "noone")},
{"parent_enabled",ini.GetValue(defIdChar, "parent_enabled", "noone")},
{"enabled",ini.GetValue(defIdChar, "enabled", "noone")},
{"items",ini.GetValue(defIdChar, "items", "noone")},
{"sklad",ini.GetValue(defIdChar, "sklad", "noone")},
{"avito_status",ini.GetValue(defIdChar, "avito_status", "noone")}
}
}
};
}
std::string sss = dataResult.dump(2);
printf(sss.c_str()); In the console, there is an option with dump and "value = " id of the objects that I need |
Beta Was this translation helpful? Give feedback.
Answered by
gregmarr
Sep 11, 2023
Replies: 1 comment 3 replies
-
I'm assuming that you want
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, so you want this: