It appears the developer here opted for a flat, denormalized structure. This is done for many reasons including performance. In fact, survey results in particular are often stored this way in OLAP systems to make search and analysis faster. Automated analysis tools usually work more seamlessly on denormalized data. Some columnar databases like Apache Druid actually require this flat format to function properly.
Sure you could structure things as you described, but then you would have to write code to denormalize it when you are storing it in your database, as opposed to just being able to stuff it right in.
to be fair, storing stuff using nesting really wastes space, like say you'd have to repeat {"question_no": <num>, "answer": <resp>} and those keys take up a lot of space, same goes for even this solution
it should be noted then that json might not be the fastest tool for this though idk what other general formats you could use
155
u/Depress-o Mar 28 '23
Goddamnit! Only if there was a way to group multiple objects in a single property using JSON...
61
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 28 '23
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
31
u/[deleted] Mar 28 '23
The only reason I can think of is if they're using some half baked home grown JSON processor
15
u/plank24 Mar 28 '23
Looks good to me. Gets the job done and everyone here understands what it does
13
u/[deleted] Mar 28 '23
The plural of "status" is "status", goddammit!
28
u/Kamoda Mar 28 '23
Where bad code
1
u/clancularius_munus Mar 29 '23
Not even bothered by the structure.
THE PL. OF STATUS IS NOT STATUSES
0
u/writetehcodez Mar 28 '23
Dear god what is this???
-13
u/YooBitches Mar 28 '23
That's fuckin abomination.