Sunday, October 9, 2011

Checking out and setting up QJSON for QT symbian

Generally JSON is simple data exchange format like xml but more simple and flexible than it. Specially when transferring data in XML format, it adds more weight to the actual information we want to transmit as information is overwhelmed by opening and closing tags. This can sometime be useful and sometime be an overhead. To avoid or reduce that overhead we can use JSON. It stands for Java Script Object Notations which can be used to transmit data over http as JSON object. There are many JSON related online references are availble in internet. Therefore What we are focusing is QJSON which is QT based library that maps JSON data to QVariant/QMap objects.

We will consider making qt lib and setting up the path properly via QT creator IDE.  qjson library is not implicitly available with default libraries comes with QT. Therefore you have to checkout qjson project source separately and then build it and generate a qjson lib file. One thing to notice is do not try to download qjson source from source forge because due to some reasons it is not the complete project for one to develop lib file they need easily. That source hides some essential files like .pro file etc which are useful to generate lib file directly by using QT Creator IDE.

For checking out the latest version of qjson, first you shoul have a git client installed in your machine. Git is a FOS distributed version management system that can be downloaded from official git site. qjson repository is hosted here. For checking out this as online from downloaded git client, usegit clone git://gitorious.org/qjson/qjson.git command and import complete latest qjson version to your local disk space.

Then open this qjson project via QT Creator and build it. It will create qjson.dll.a lib file under build/lib folder of qjson source. It is like your_disk_name:/qjson-0.7.1/qjson/build/lib/qjson.dll.a. Now all you have to do is to tell QMake in your .pro where is located your header files and lib file.

Ex: type as following in any where of your .pro file
INCLUDEPATH += "c:/qjson-0.7.1/include"
LIBS += "c:/qjson-0.7.1/qjson/build/lib/qjson.dll.a"
 
That's it. Enjoy qjson in QT. Some initiative code snippets on qjson for qt can be found here.


 


No comments: