Solved Using QJson functionality to change data in nested json with arrays.
-
Here is a problem I have been struggling with for a few hours and am not close to solving. How can I change id and recording-id from 0 to 1.
{ recordings: [{ id: 0 }], data-source-storages: [{ sample-storages: [{ recording-id: 0 }] }] }
-
@pokemonsrqt What did you try and what is not working?
Start here: http://doc.qt.io/qt-5/qjsondocument.html -
This is where I am at
QJsonArray recordings = obj.value(JSON::V0_1::KEYS::RECORDINGS).toArray(); for(QJsonValue recording : recordings) { QJsonObject recordingObj = recording.toObject(); recordingObj.remove("id"); recordingObj.insert("id", DataStorage::availableRecordingId()); }
The major problem is that changing the local variable recordingObj does not change the outer variable obj that is the one I want to change.
-
-
Thanks! That helped big time!