Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON classes in Qt vs other JSON parsers in C++

Tags:

c++

json

qt

I'm developing a server/client application in C++ and im using Qt as my IDE as well as some of its libraries. Performance-wise i was told that one of the best ways to transfer data between a server and client was via JSON. However i would like to know the performance differences between the default classes for parsing JSON in Qt (QJsonArray,QJsonObject.. etc) and other C++ parsers, like JSON++ for example..

like image 620
loukwn Avatar asked Oct 26 '25 05:10

loukwn


1 Answers

If Qt classes are not performant enough, you can look at RapidJson: https://github.com/miloyip/rapidjson

Performance comparision: http://code.google.com/p/rapidjson/wiki/Performance

Good thing about RapidJson (apart from its speed) is easy installation and usage. From their website:

rapidjson is a header-only library. That means, the only thing to be done is to copy rapidjson/include/rapidjson and its sub-directories to your project or other include paths.

And example also from their wiki page:

#include "rapidjson/document.h"
#include <cstdio>

int main() {
    const char json[] = "{ \"hello\" : \"world\" }";

    rapidjson::Document d;
    d.Parse<0>(json);

    printf("%s\n", d["hello"].GetString());

    return 0;
}
like image 170
Googie Avatar answered Oct 27 '25 19:10

Googie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!