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 ()
}