How to use QJson in Qt creator (Qt 4.8.6)
-
I want to use QJson in Qt creator, I'm using Qt 4.8.6 so there is no Json lib in the QtCore like in Qt5.
I have been to the "official sourceforge site":http://qjson.sourceforge.net/build/ and it says that I should install qjson using package manage tools. So I installed libqjson0, libqjson-dev, libqjson-dbg and libqjson0-dbg package using apt-get install.
Than I created a new project and copy the official site's example to it. I alse modified my .pro file, I added an external library (libqjson.so) so Qt creator automatically added the following code to the .pro file:
@win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../usr/lib/x86_64-linux-gnu/release/ -lqjson
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../usr/lib/x86_64-linux-gnu/debug/ -lqjson
else:unix: LIBS += -L$$PWD/../../../../../../usr/lib/x86_64-linux-gnu/ -lqjson
INCLUDEPATH += $$PWD/../../../../../../usr/lib/x86_64-linux-gnu
DEPENDPATH += $$PWD/../../../../../../usr/lib/x86_64-linux-gnu
@
The libqjson.so file is in the x86_64-linux-gnu path.
I also added a line including the parse.h file and other files with it:
@INCLUDEPATH += $$PWD/../../../../../../usr/include/qjson@After that, I can include <parser.h>, but I can't use the function like toMap(), toString() in my code...
I think there must be something wrong in my install procedure.
Does anyone has an experience about installing QJson? Help Please! -
Hi,
Indeed, Qt 4.X doesn't have support for json.
I would say that INCLUDEPATH doesn't contain the correct path to QJson's headers, correct it and you should be good to go