I need to parse JSON object through Qt. What is the easiest/fastest way to do it?
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- QML: Cannot read property 'xxx' of undefin
- StackExchange API - Deserialize Date in JSON Respo
- Correctly parse PDF paragraphs with Python
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- json_encode 没有把数组转为json
- Livy Server: return a dataframe as JSON?
- Unexpected end of JSON input from an ajax call
- How do I get from a type to the TryParse method?
- How do I do a nested list (array) of schema refere
- Is there a non-java, cross platform way to launch
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
JSON parsing is now supported in Qt 5. Here's how to load and parse a document:
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/
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 :-).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:Here is Qt style json encoder/decoder