On 03/19/2012 10:36 AM, Jean-Michel Caricand wrote:
> #include<iostream>
> #include<sstream>
> #include<cxxtools/jsonserializer.h>
>
> using namespace std;
> using namespace cxxtools;
>
> int main(int argc, char *argv[])
> {
> string s1 = "Anaïs";
> ostringstream o;
>
> JsonSerializer serializer(o);
> //serializer.beautify(true);
> serializer.serialize(s1, "s1");
> serializer.finish();
>
> cout<< "s1: "<< s1<< endl;
> cout<< "json : "<< o.str()<< endl;
>
> return 0;
> }
Hi,
You should use cxxtools::String, which is a std::basic_string with
unicode. The example looks like this then:
#include <iostream>
#include <sstream>
#include <cxxtools/jsonserializer.h>
using namespace std;
using namespace cxxtools;
int main(int argc, char *argv[])
{
String s1 = L"Anaïs";
ostringstream o;
JsonSerializer serializer(o);
//serializer.beautify(true);
serializer.serialize(s1, "s1");
serializer.finish();
cout << "s1: " << s1 << endl;
cout << "json : " << o.str() << endl;
return 0;
}
And it works. Output is this here:
$ g++ -o json -lcxxtools json.cpp
$ ./json
s1: Anaïs
json : {"s1":"Ana\u00efs"}
Tommi
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general