Answer the question
In order to leave comments, you need to log in
How to store schedule data?
Good day! I have a couples schedule at the university. I need to somehow store this in JSON. A pair may differ in a week (the numerator and denominator, i.e. a week - this pair, a week - another), but it may not differ: the pair can be divided into subgroups. Then from all it is necessary to build the table. There is an idea - to store a separate object of the type "common pair" and "common for the denominator and numerator". But there are doubts through the repetition of data.
code something like this:
[
[
{
"num":{
"first":{
"name": "some name",
"where": "V. 210",
"who": "Torubka"
},
"second":{},
},
"dem":{
"first":{},
"second":{},
},
"together":{
"first":{
},
"second":{
},
"together":{
}
}
},
{
},
{
}
],
[
],
]
Answer the question
In order to leave comments, you need to log in
IMHO, you're driving. Repetition in two or three objects is nothing to worry about.
I would keep it that way.
General template:
json = {
"data": {
"chislitel": {
"mon": [
{
"name": "some name",
"where": "V. 210",
"who": "Torubka"
},
...
],
"tue": [
{
"name": "some name",
"where": "V. 210",
"who": "Torubka"
},
...
],
...и так на каждый день недели
},
"znamenatel": {
...такая же логика
}
}
}
weeks = [
{
"start": "01.01.2017",
"end": "05.01.2017",
"type": "chislitel"
},
{
"start": "08.01.2017",
"end": "12.01.2017",
"type": "znamenatel"
},
...
]
for week in weeks:
вписать в таблицу значение json["data"][week.type]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question