Skip to content

Instantly share code, notes, and snippets.

@fernandoc1
Created December 22, 2016 17:13
Show Gist options
  • Save fernandoc1/dd955a9655a94ef4f2890af152c475c4 to your computer and use it in GitHub Desktop.
Save fernandoc1/dd955a9655a94ef4f2890af152c475c4 to your computer and use it in GitHub Desktop.
Boost JSON property tree example
{
"str_value": "string value",
"int_value": 10
}
#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;
}
all:
g++ main.cpp -lboost_system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment