QJson is actively developed (and used by KDE, if I'm not mistaken). The best is to checkout the source code directly and built it yourself. There is no dependencies to QJson (except for Qt and CMake). It's pretty simple to use too, have a look at some usage examples :
This library is indented to be a drop in replacement for QJsonDocument in Qt4 and will use Qt's classes when used in Qt5. So it should be a fairly smooth transition. It's not 100% complete, but the major features are in there :-).
发布评论
评论(6)
尝试 QJson。
QJson 正在积极开发(并且由 KDE 使用,如果我没记错的话)。最好的办法是直接查看源代码并自己构建。对 QJson 没有依赖关系(Qt 和 CMake 除外)。使用起来也非常简单,看看一些用法示例:
http://qjson.sourceforge.net/usage /
Try QJson.
QJson is actively developed (and used by KDE, if I'm not mistaken). The best is to checkout the source code directly and built it yourself. There is no dependencies to QJson (except for Qt and CMake). It's pretty simple to use too, have a look at some usage examples :
http://qjson.sourceforge.net/usage/
Qt 5 现在支持 JSON 解析。以下是加载和解析文档的方法:
JSON parsing is now supported in Qt 5. Here's how to load and parse a document:
如果您不想依赖外部库,您可以使用 QScriptEngine
http://qtwiki.remdex.info/ Parsing_JSON_with_QT_using_standard_QT_library
If you don't want to depend on external libraries you could use the QScriptEngine
http://qtwiki.remdex.info/Parsing_JSON_with_QT_using_standard_QT_library
这是Qt风格的json编码器/解码器
Here is Qt style json encoder/decoder
我知道这个答案已经晚了,但我最近创建了一个项目来帮助创建代码,该代码旨在在 Qt4 和 Qt5 上编译并处理 JSON。
https://code.google.com/p/qjson4/
该库缩进为Qt4 中 QJsonDocument 的替代品,并且在 Qt5 中使用时将使用 Qt 的类。所以这应该是一个相当平稳的过渡。它不是 100% 完整,但主要功能都在其中:-)。
I know this answer is late, but I recently created a project to help create code which is meant to compile on both Qt4 and Qt5 and deals with JSON.
https://code.google.com/p/qjson4/
This library is indented to be a drop in replacement for
QJsonDocument
in Qt4 and will use Qt's classes when used in Qt5. So it should be a fairly smooth transition. It's not 100% complete, but the major features are in there :-).我推荐 qjson-backport,因为它使用与 Qt5 中相同的 API。
使用Qt4时可以有条件地加载库,使用Qt5时使用默认实现。
我的 qjson.pri 文件如下所示:
I would recommend qjson-backport, as it uses the same API as in Qt5.
You can conditionally load the library when you use Qt4, and use the default implementation when using Qt5.
My
qjson.pri
file looks like: