JSON parsing on the qt Platform

Source: Internet
Author: User

I have studied JSON parsing on the qt platform over the past few days.
Because there are many methods, I am also dizzy.
This is also a little bit of achievement.

There are many ways to parse JSON on the qt Platform
1. The system provides qscriptengine qscriptvalue to parse JSON
2. The QT platform has an open-source qjson library. This package is easy to use,
I found that two-dimensional Parsing is not possible during debugging. Depressed. I don't know if it's my character.
3. I took the time to port the Open Source library libjson pure C to QT. The Internet is said to be the fastest open-source library. .
The first time I transplanted open-source things on the qt platform, I felt that it was really fast to transplant it on QT. Compared to the workload of Symbian porting. That can be ignored.
Of course there are other JSON parser, which can also be transplanted.

Libjson is the parsing library I use on Symbian, so it is easy to use. Comfortable.
However, libjson has a disadvantage. keywords MUST be included during parsing.

Because the last two are open-source parsing, there is not much to introduce.
Let's simply talk about the usage of the parser that comes with the system.

// Initialize a piece of data
Qbytearray result =/"{//" foo // ": //" bar // ", //" number ///": 51.3 }/";

Qscriptvalue SC;
Qscriptengine engine;
SC = engine. Evaluate (/"value =/" + qstring (result); // note that this must be used here. I don't know why. I did not study it.
// In new versions it may need to look like engine. Evaluate (/"(/" + qstring (result) + /")/");

qscriptvalueiterator it (SC);
while (it. hasnext () {
it. next ();
// print the output value
qdebug ()
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.