JSON data format for MCQ data bank
I'm creating a data bank of MCQ (Multi Choice Questions) and their answers so that an app can be built around it. Regarding the actual storage format, I have two ideas: An array of objects with...
I'm creating a data bank of MCQ (Multi Choice Questions) and their answers so that an app can be built around it. Regarding the actual storage format, I have two ideas:
- An array of objects with keys (
q
for question,a
for choice-a, etc.). - An array of arrays.
The first one is obviously more readable. Here is a brief sample of what I have so far:
{
"data": [
{
"q": "What kind of language is Python?",
"a": "Compiled",
"b": "Interpreted",
"c": "Parsed",
"d": "Elaborated",
"r": "b"
},
{
"q": "Who invented Python?",
"a": "Rasmus Lerdorf",
"b": "Guido Van Rossum",
"c": "Bill Gates",
"d": "Linus Torvalds",
"r": "b"
}
]
}
The app will read the q key to print the question, then present the four options (a, b, c and d). And the last key (r) will store the right answer. This is very much readable when viewed as a JSON file also. However, what I am thinking is that once the data-bank grows in size into hundreds/thousands of QA, a lot of space will be wasted by those keys (q,a,b,etc.) isn't it? In this case, an array like this is more efficient from storage perspective:
{
"data": [
[
"What kind of language is Python?",
"Compiled",
"Interpreted",
"Parsed",
"Elaborated",
1
],
[
"Who invented Python?",
"Rasmus Lerdorf",
"Guido Van Rossum",
"Bill Gates",
"Linus Torvalds",
1
]
]
}
In this case, each array will have 6 items viz. the question, four choices and finally the index of the correct choice (1==Interpreted, etc.).
Which of these two formats is better? Feel free to suggest any third format which is even better than these two.