How to use boost::property_tree to parse JSON with array root
问题 How can I get data from JSON with array as root node by using Boost.PropertyTree? [ { "ID": "cc7c3e83-9b94-4fb2-aaa3-9da458c976f7", "Type": "VM" } ] 回答1: The array elements are just values with a key named "" for property tree: for (auto& array_element : pt) { for (auto& property : array_element.second) { std::cout << property.first << " = " << property.second.get_value<std::string>() << "\n"; } } Prints ID = cc7c3e83-9b94-4fb2-aaa3-9da458c976f7 Type = VM Live On Coliru #include <boost