There are 2 "arrays". In JSON MySQL 5.7.
The first one is a set of user answers to the questions of the test of the form <question_number> {<answer_number>}, ...
The second is a list of keys on 6 scales.
1) User answers to test questions:
{ "answers" : { "1" : [ "2" ], "10" : [ "1" ], "11" : [ "1" ], "12" : [ "2" ], "13" : [ "1" ], "14" : [ "1" ], "15" : [ "1" ], "16" : [ "1" ], "17" : [ "1" ], "18" : [ "1" ], "19" : [ "1" ], "2" : [ "3" ], "20" : [ "1" ], "21" : [ "1" ], "22" : [ "1" ], "23" : [ "3" ], "24" : [ "1" ], "3" : [ "2" ], "4" : [ "1" ], "5" : [ "1" ], "6" : [ "1" ], "7" : [ "1" ], "8" : [ "3" ], "9" : [ "1" ] }, "test" : "profexposure" }
2) Keys collected in Scales. Simplify format <name of the scale> {<number of the question>: {<number of the answers>}}
"counting" : { "scales" : { "Общительность" : { "answers" : { "1" : 1, "11" : 1, "14" : 1, "16" : 1, "19" : 1, "21" : 1, "23" : 1, "25" : 1, "27" : 1, "29" : 1, "3" : 1, "32" : 1, "34" : 1, "37" : 1, "39" : 1, "5" : 1, "8" : 1 } }, "Стабильность" : { "answers" : { "10" : 1, "13" : 1, "15" : 1, "17" : 1, "2" : 1, "20" : 1, "22" : 1, "26" : 1, "28" : 1, "31" : 1, "33" : 1, "35" : 1, "38" : 1, "4" : 1, "40" : 1, "7" : 1, "9" : 1 } }, "Шкала лжи" : { "answers" : { "12" : 2, "18" : 2, "24" : 2, "30" : 2, "36" : 2, "6" : 2 } } } } How do I actually count how many points for each scale is scored?
PS I did similar before without JSON in MySQL, but now I use JSON MySQL 5.7, because with it information like "psychological tests" (for several dozen tests with different rules of calculation), it is more convenient to store in JSON, more readable, easier, etc.