久しぶりにC++ネタ。JSONを生成するプログラムをC++で書こうなんて人がそもそもいない気もするが、boost::property_tree::write_json()
を使うと簡単にJSON出力ができる。
1 | #include <iostream> |
2 | #include <sstream> |
3 | #include <boost/property_tree/json_parser.hpp> |
6 | int main( int argc, char *argv[]) |
10 | cerr << "Usage: " << argv[0] << " message" << endl; |
14 | boost::property_tree::ptree pt; |
15 | pt.put("message", argv[1]); |
16 | boost::property_tree::write_json(cout, pt, false ); |
Continue reading »