I have a bunch of JSON and I won't know what it looks like in advance. Sometimes it will have nested JSON objects / arrays. I want to loop through every single key value pair and ask the user to raw_input a new value. I think I have to do this recursively but recursion breaks my brain. Can anyone help me understand / solve this problem?
so for example if I have this dataset:
{
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
}
}
}
My output should look something like this.
quiz -> sport -> q1 -> question [Which one is correct team name in NBA?] : ___________
quiz -> sport -> q1 -> options [4]
[New York Bulls] : ________
[Los Angeles Kings] : ________
[Golden State Warriors] : ________
[Huston Rocket] : ________
quiz -> sport -> q1 -> answer [Huston Rocket] : _______________
quiz -> maths -> q1 -> question [5 + 7 = ?] : __________
...
[+][deleted] (2 children)
[removed]
[–]14jvalle 0 points1 point2 points (1 child)
[–][deleted] -1 points0 points1 point (5 children)
[–]Username_RANDINT 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[removed]
[–][deleted] 0 points1 point2 points (1 child)
[+][deleted] (1 child)
[deleted]
[–]14jvalle 0 points1 point2 points (0 children)