M
M
mynewvk2017-03-12 00:01:53
JSON
mynewvk, 2017-03-12 00:01:53

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

1 answer(s)
A
AdaStreamer, 2017-03-12
@AdaStreamer

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": {
      ...такая же логика
    }
  }
}

then we generate the schedule itself. this is an example of data, it can be generated in any way
weeks = [
  {
    "start": "01.01.2017",
    "end": "05.01.2017",
    "type": "chislitel"
  },
  {
    "start": "08.01.2017",
    "end": "12.01.2017",
    "type": "znamenatel"
  },
  ...
]

well, then generate a table
for week in weeks:
  вписать в таблицу значение json["data"][week.type]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question