-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Qt JSON types support This adds support for Qt’s JSON types as proposed in the comment of PR #5. The difficulty in using Qt’s JSON data types was that they can be casted to QVariantList/QVariantHash if they are inside a QVariant and e.g. `QVariant::canConvert<QVariantList>` returns true for a QJsonArray, but the next step by Cutelee is to cast them into QAssociativeIterable or QSequentialIterable. That only works for template based containers. So, my solution is to “intercept“ this types before the QVariant cast is tried and convert them directly into QVariantList or QVariantHash. If the JSON type is direct part of the context, this happens in `Cutelee::Variable::resolve()`, if the JSON type is stored in a context variable’s property or further down the road, the lookup will be done in `Cutelee::MetaType::lookup()`. Unit tests are currently written to test “normal“ usage as variable and to be used in a `{% for %}` loop tag. Maybe we should add some more tests to see if they play nicely with filters and the rest, even though I think that this implementations should make this possible without further changes. * Use QJsonValue::toVariant() in Variable::resolve() Make the switch a bit simpler and convert directly to QVariant. * Use QJson data types in JSON lookup functions
- Loading branch information
1 parent
35e7dbf
commit 2e7317d
Showing
3 changed files
with
471 additions
and
1 deletion.
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
Oops, something went wrong.