Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.1.1
-
None
-
a7823b487808a869d4bdc3ff20fddb04967211e1
Description
QJsonValue is the return type by QJsonObject["key"] and QJsonArray[1].
If QJsonValue supports [] operator, then value retrieval sequence will be more easily chained.
Say,
the json contained in the QJsonObject p,
{ "a": [ {"t1": "t2"}, {"t3": "t4"} ], "b": { "c": "d" } }
If I want to get the "t4" value, I need to write,
p["a"].toArray()[1].toObject()["t3"].toString()
If the [] operator is added to QJsonValue, I can write it as,
p["a"][1]["t3"].toString()
which will be significantly shorter and easier to understand.
Also, it should be possible to implement since the parameter type passed to [] operator is different, one is int and one is string. And the return types can be the same QJsonValue. So there should be syntax problem.