[Interest] Qt 5: Converting QJsonValue to QJsonArray
lars.knoll at nokia.com
lars.knoll at nokia.com
Mon Aug 13 15:24:04 CEST 2012
On Aug 8, 2012, at 9:14 PM, ext Stephen Chu <stephen at ju-ju.com> wrote:
> I am trying out the new QJsonValue in Qt 5 and find myself wondering:
> Does converting a QJsonValue which is an array to a QJsonArray with
> QJsonValue::toArray() makes a copy of the underlying data?
>
> Say I load a JSON file which is an object that contains an array with
> thousands of items using QJsonDocument:
>
> auto myObj = QJsonDocument::fromJson(jsonData).object();
> auto myArray = myObject["theArray"].toArray();
>
> How efficient is the conversion? Does it make a deep copy of the data in
> the original object to the new array?
No it doesn't make any deep copies as long as the data is not being modified.
Cheers,
Lars
More information about the Interest
mailing list