-
Notifications
You must be signed in to change notification settings - Fork 5
Wrong array index processed #3
Copy link
Copy link
Open
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels