The QMJsonArray implements a JSON array. Internally, the QMJsonArray is a QList<QMPointer<QMJsonValue> >. Thus, all of the rules that apply to QList with respect to performance are basically the same with QMJsonArray. Like the rest of the QtMark JSON Library, all of the QMJsonValues stored in the QMJsonArray as stored as QMPointers.
Like all of the classes in this library, QMJsonArray must be created using a managed QMPointer.
There are a number of ways to add to QMJsonArray:
There is no needed to manually wrap a value in a QMJsonValue, as this will be done for you:
There are also a number of functions to remove an item from the QMJsonArray. The major ones are:
QMJsonArray::isEmpty will tell you if the QMJsonArray has any QMJsonValues in it. You can also call QMJsonArray::count to get the current number of QMJsonValues in the QMJsonArray.
There are number of functions that perform their operations by doing a lookup using an existing QMJsonValue.
These functions do a pointer comparison to validate that QMJsonValue being referenced has been found. This means that currently, you cannot create a second QMJsonValue with the same wrapped value, and expect these functions to perform the intended results.
Both the QMJsonObject and QMJsonArray classes provide the QMJsonValue unwrap functions for convenience. This applies for:
Allowing for shorthand conversions:
To convert a QMJsonArray to JSON, you must wrap the QMJsonArray in a QMJsonValue and use QMJsonValue::toJson and QMJsonValue::fromJson