shokai / json-builder

json builder for C++. convert from std::map and std::vector to json string.

Clone this repository (size: 49.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/shokai/json-builder/
json-builder / test / test.cpp
r8:abbc9d0a382d 20 loc 480 bytes embed / history / annotate / raw /
#include <iostream>
#include <string>
#include <map>
#include <boost/any.hpp>
#include "../json_builder.h"

int main(int argc, char* argv[]){
  std::map<string,boost::any> user;
  user["name"] = std::string("shokai");
  user["fullname"] = std::string("sho hashimoto");
  user["age"] = 25;
  user["test"] = 1.23;
  user["null"] = json_builder::null;
  user["true"] = true;
  user["false"] = false;

  string json = json_builder::toJson(user);
  cout << json << endl;
  return 0;
}