'JSON Database doesn't work correctly as per REST technique

I created a JSON server and this is the data that I'm using. However, when I'm trying to query the examlist and relate it to the students (i'd like to receive the students based on their ID (the picture below shows the REST query - I'm using ?_expand=student )) it won't display them. The code shows correct as per JSON validators, but my goal is to have them working. The way my data is organized (the examlist table) won't display the students, because apparently, it cannot read their IDs. This database will be used for HTTP requests, hence I need it fully working.

I'll upload another image so that you can visualize my code. Momentarily instead of my studentIDs, it's showing some random 0,1 numbers and the student IDs are being pushed down along the arbitrary tree.

enter image description here (Just the examlist "table")

It's M:M relationship (relational database) and how I want it structured is:

  • Table "students" that contains information about the students;
  • I have "table" exams that contains information about the exams;
  • And then I have another "table" examlist which contains information about the EXAM (ExamID) and the students enrolled in it (basically relates the two abovementioned tables)

When I try querying the students through the "examlist" table, it won't work. However, the other "table" -- exam, does work.

My assumption is the way I have organized the students in the examlist "table" is not good, however, given my very little experience I cannot seem to see where the issue is.

I hope I cleared it out for the most of you! Sorry for any inconvenience caused.

{
  "students": [
    {
      "id": 3021,
      "nume": "Ionut",
      "prenume": "Grigorescu",
      "an": 3,
      "departament": "IE"
    },
    {
      "id": 3061,
      "nume": "Nadina",
      "prenume": "Pop",
      "an":3,
      "departament": "MG"
    },
    {
      "id": 3051,
      "nume": "Ionut",
      "prenume": "Casca",
      "an": 3,
      "departament": "IE"
    }
  ],
  "exams": [
    {
      "id": 1,
      "subiect": "Web Semantic",
      "profesor": {
        "Nume": "Robert Buchman"
      }
    },
    {
      "id": 2,
      "subiect": "Programare Web",
      "profesor": {
        "Nume": "Mario Cretu"
      }
    },
    {
      "id": 3,
      "subiect": "Medii de Programare",
      "profesor": {
        "Nume": "Valentin Stinga"
      }
    }
  ],
"listaexamene": [
      {
         "examId":1,
         "Data Examen":"02/06/2022 12:00",
         "studentId": 
        [
            {
               "id":3021
            },
            {
               "id":3051
            }
        ]
      },
      {
         "examId":2,
         "Data Examen":"27/05/2022 10:00",
         "studentId":
        [
            {
               "id":3021
            },
            {
               "id":3051
            }
        ]
      },
      {
         "examId":1,
         "Data Examen":"04/06/2022 10:00",
         "studentId":
        [
            {
               "id":3021
            },
            {
               "id":3051
            },
            {
               "id":3061
            }
        ]
      }
   ]
}

enter image description here enter image description here

I had to repost with more information after my first one got closed down



Solution 1:[1]

I think I finally got the answer. The problem lays in the JSON server. Apparently, it cannot obtain information from further down the arbitrary tree, only the first layer.

Thank you all for your input on the previous post!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stef2nn