How to serialize to JSON in Qt

你说的曾经没有我的故事 提交于 2019-12-03 06:22:27

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());
chalup

Parsing JSON with QT using standard QT library.

BTW: why don't you want to use QJson? It nicely encapsulates all the QScriptValueIterator stuff, making your code easier to read.

See this JSON Save Game example on serialization of an object to a JSON document.

There are no internal tools in Qt to do it. You will have to use a lib. Or roll your own implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!