我想使用Boost (Property Tree)库来解析以下有效的JSON文件:
{
"user": {
"userID": "5C118C8D-AA65-49C0-B907-348DE87D6665",
"dateProperty": "05-06-2015"
},
"challenges": [
{
"question#1": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
},
{
"question": "answer",
"value": 5
}
] }
我已经确认JSON格式正确。
我还咨询了几个网站,例如:
- Boost 1.46.1,Property Tree:如何遍历接收子ptrees?
- http://www.technical-recipes.com/2014/using-boostproperty_tree/
但是我仍然没有得到正确的结果。我想将“user”和“challenges”作为键值对收集起来。最好的结果是将“challenges”(问题/答案)和用户信息(userID,dateProperty)写入std::pair中,然后可以将其写入std:map。
任何建议都会受到赞赏。