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/

Changed (Δ54 bytes):

raw changeset »

json_builder.h (2 lines added, 1 lines removed)

test/test.cpp (1 lines added, 1 lines removed)

Up to file-list json_builder.h:

6
6
#include <boost/tuple/tuple.hpp>
7
7
#include <boost/format.hpp>
8
8
#include <boost/foreach.hpp>
9
#include <boost/regex.hpp>
9
//#include <boost/regex.hpp>
10
10
11
11
using namespace std;
12
12
using namespace boost;
@@ -45,6 +45,7 @@ namespace json_builder{
45
45
    }
46
46
    else if(value.type() == typeid(int)){
47
47
      int n = any_cast<int>(value);
48
      if(n == NULL) return string("null");
48
49
      return str(format("\"%d\"") % n);
49
50
    }
50
51
    else if(value.type() == typeid(double)){

Up to file-list test/test.cpp:

@@ -10,7 +10,7 @@ int main(int argc, char* argv[]){
10
10
  user["fullname"] = std::string("sho hashimoto");
11
11
  user["age"] = 25;
12
12
  user["test"] = 1.23;
13
  //  user["null"] = JSON_NULL;
13
  user["null"] = NULL;
14
14
  user["true"] = true;
15
15
  user["false"] = false;
16
16