Created
December 22, 2016 17:13
-
-
Save fernandoc1/dd955a9655a94ef4f2890af152c475c4 to your computer and use it in GitHub Desktop.
Boost JSON property tree example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"str_value": "string value", | |
"int_value": 10 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/property_tree/json_parser.hpp> | |
#include <boost/property_tree/ptree.hpp> | |
int main() | |
{ | |
boost::property_tree::ptree pt; | |
boost::property_tree::json_parser::read_json("config.json", pt); | |
std::cout << pt.get<std::string>("str_value") << std::endl; | |
std::cout << pt.get<int>("int_value") << std::endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
g++ main.cpp -lboost_system |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment