'how to properly nest json data that is related
I have some data which is defined with such cardinality:
1. School
1.1. Student
1.1.1 Homework
Parkside
John Smith
Reading assignment abc
Score 100
Reading assignment def
Score 90
Reading assignment xyz
Score 85
Lenny Bones
Reading assignment 789
Score 20
There can be many homeworks that belong to a student, and the student always rolls up to a school.
I would like to know if I am nesting my data properly in a JSON structure, or if there is a better approach.
{
"items": {
"Parkside": {
"John Smith": [
{
"ra": "Reading assignment abc",
"score": 100
},
{
"ra": "Reading assignment def",
"score": 90
},
{
"ra": "Reading assignment xyz",
"score": 85
}
],
"Lenny Bones": [
{
"ra": "Reading assignment 789",
"score": 20
}
]
}
}
}
I'm confused whether it is good to use value definitions as keys, or if I should design the JSON structure to always use the same key for the given attribute.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
