Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serialize to JSON in Qt

How can I JSON serialize a QVariant (or other type of data) in Qt. I don't want to use an external third party library like QJson

like image 513
user457015 Avatar asked Feb 13 '11 23:02

user457015


1 Answers

Just to mention, as of Qt5, JSON is officially supported:

JSON Support in Qt

QVariant id(1), name("John Doe");
QJsonObject json;

json["Name"] = name.toString();
json.insert("id", id.toInt());
like image 158
dtech Avatar answered Oct 10 '22 09:10

dtech