Consider the following example:
` QJsonArray arr;
{
QJsonObject obj;
obj["name"] = "John";
obj["id"] = "1";
arr.push_back(obj);
}
{
QJsonObject obj;
obj["name"] = "Jane";
obj["id"] = "2";
arr.push_back(obj);
}
QJsonDocument doc(arr);
modifyJsonValue(doc, "[1].id", 3);
qDebug() << doc;
This results in:[{"id":"1","name ":"John"},{"id":3,"name":"John"}]`
The issue seems to be Ln 121:
subValue = destValue.toArray()[usedPropertyName.toInt()];
usedPropertyName is empty which results in casting to 0 instead of the actual index (1). Replacing the line with:
subValue = destValue.toArray()[arrayIndex];
seems to work.
Consider the following example:
` QJsonArray arr;
{
QJsonObject obj;
obj["name"] = "John";
obj["id"] = "1";
arr.push_back(obj);
}
{
QJsonObject obj;
obj["name"] = "Jane";
obj["id"] = "2";
arr.push_back(obj);
}
This results in:[{"id":"1","name ":"John"},{"id":3,"name":"John"}]`The issue seems to be Ln 121:
subValue = destValue.toArray()[usedPropertyName.toInt()];usedPropertyName is empty which results in casting to 0 instead of the actual index (1). Replacing the line with:
subValue = destValue.toArray()[arrayIndex];seems to work.