-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from oblivioncth/dev
Merge to master for v0.6
- Loading branch information
Showing
70 changed files
with
8,617 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Major Features {#majorfeatures} | ||
=============================== | ||
|
||
This page catalogues the most significant features of Qx, which generally form a complete/comprehensive system that can be evaluated independently from the rest of the library. | ||
|
||
- @subpage properties "Bindable Properties System" | ||
- @subpage declarativejson "Declarative JSON" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
Qx Declarative JSON {#declarativejson} | ||
====================================== | ||
|
||
Qx features a highly flexible, simple to use, declarative mechanism for parsing/serializing JSON data into user structs and other types. | ||
|
||
For example, the following JSON data: | ||
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.json} | ||
{ | ||
"title": "Sample JSON Data", | ||
"info": { | ||
"rating": 10, | ||
"cool": true | ||
}, | ||
"reviews": [ | ||
"Wicked!", | ||
"Awesome!", | ||
"Fantastic!" | ||
] | ||
} | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
can easily be parsed into a corresponding set of C++ data structures like so: | ||
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} | ||
#include <qx/core/qx-json.h> | ||
struct Info | ||
{ | ||
int rating; | ||
bool cool; | ||
QX_JSON_STRUCT(rating, cool); | ||
}; | ||
struct MyJson | ||
{ | ||
QString title; | ||
Info info; | ||
QList<QString> reviews; | ||
QX_JSON_STRUCT(title, info, reviews); | ||
}; | ||
int main() | ||
{ | ||
QFile jsonFile("data.json"); | ||
MyJson myJsonDoc; | ||
// Parse into custom structures | ||
Qx::JsonError je = Qx::parseJson(myJsonDoc, jsonFile); | ||
Q_ASSERT(!je.isValid()); | ||
... | ||
} | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Likewise, the structure can be serialized back out into textual JSON data with: | ||
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} | ||
int main() | ||
{ | ||
... | ||
// Serialize to JSON | ||
je = Qx::serializeJson(jsonFile, myJsonDoc); | ||
Q_ASSERT(!je.isValid()); | ||
} | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
This system is accessed through the qx-json.h header, predominantly with QX_JSON_STRUCT(). |
Oops, something went wrong.