I am creating a revision app and I would like to update the variable incorrect from 0 to 3 after user has answered all the questions. Data is stored as below in a json file. The number of times a question as been answered incorrectly is stored in memory as of now, but I would like it to be written into the json file so it is not lost after the program is closed. How can I do this?
TLDR: I want to update it from this:
"incorrect": [
0,
0,
0,
0
],
to this
"incorrect": [
3,
0,
0,
0
],
{
"question": [
"Q1. What is the equation for force?",
"Q2. Define isotope",
"Q3. Define wavelength",
"Q4. Define modal dispersion"
],
"answers": [
"1",
"1",
"1",
"1"
],
"automark": [
["force=massxacceleration"],
["same number of protons", "different number of neutrons", "same element"],
["minimum distance between adjacent particles", "particles which are in phase"],
["different angles", "different times"]
],
"markscheme": [
["force=massxacceleration"],
["same number of protons", "different number of neutrons", "same element"],
["minimum distance between adjacent particles", "particles which are in phase"],
["different angles", "different times"]
],
"mastery": [
0,
0,
0,
0
],
"incorrect": [
0,
0,
0,
0
],
"correct": [
0,
0,
0,
0
],
"partiallycorrect": [
0,
0,
0,
0
]
}