问题描述
我对使用 boost 和 json 文件格式完全陌生。我想生成如下所示的 json 文件:-
{
teams:[
{team1:[team2,team3]},{team2:[team4,team5]}
]
}
我尝试的是......
using TeamList = std::vector<std::string>;
using TeamToTeamList = std::unordered_map<std::string,TeamList>;
void writeTeamToTeamList(ptree& teams)
{
TeamToTeamList tl = translateTeamToTeamList();
for(const auto& team: tl)
{
ptree teamNode;
for(const auto& accesibleTeam : team.second)
{
ptree accTeamNode;
accTeamNode.put("",accesibleTeam );
teamNode.push_back(make_pair("",accTeamNode));
}
teams.push_back(make_pair(team.first,teamNode));
}
}
来电者是:-
ptree root;
ptree groups;
writeGroupToGroupList(groups);
root.add_child("groups",groups);
我能够生产的是:-
{
teams:{
team1:[team2,team3],team2:[team4,team5]
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)