lundi 13 décembre 2010

CAMP JSON Serializer

I wrote the last week an module for CAMP for an output to JSON.

There was already one existing called camp-json but it uses a c library behind, that obliged to have another dependency and an additional memory structure before the serialization.

I removed this dependency and the additional structure by serializing directly in JSON.
I also detect if Qt is used in CAMP and I output the Qt String into UTF-8, as I think it is the standard on the web.

so you can use it like:


    MyClass o;
    camp::UserObject object = o;

    QString json;
    QTextStream ts( &json );

    camp::json_serializer::serialize( ts, object, "nojson" );
    ts.flush();
    std::cout << json.toStdString();

You can find the module source code here, the CAMP forum

I would be very happy to hear your comments and critics.

bye

Aucun commentaire:

Enregistrer un commentaire