Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong array index processed #3

Open
knopkem opened this issue Aug 16, 2018 · 0 comments
Open

Wrong array index processed #3

knopkem opened this issue Aug 16, 2018 · 0 comments

Comments

@knopkem
Copy link

knopkem commented Aug 16, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant