Many to many relationships in JSON -
Consider this scenario:
You want to send some data to the customer in JSON format, and You do not want to go back to the server, there are 15 teachers with 100 teachers in the data. There are many relations between these institutions (each student learns many teachers and every teacher teaches many students)
In the customer, the user is presented with a list of students. On the click of any student, the list of their teachers will be given to the user, and on the click of a teacher, the list of all the students of that teacher will be presented. As a result, the result of infinite click-through style navigation from students to teachers and vice-workers is the result of navigation.
Now, as you know, JSON represents one-to-many relationships in this form only:
["T1", "T2"], "S2": ["T2", "T4"], "S3": ["T1", "T3", "T4"], ...}Do you have any ideas about doing this?
As there is no concept of references in JSON, you do not need to worry about them . Which defines whether the relationship between teachers and students is located outside the data, that is, during the runtime, it is only a matter of your interpretation through the identifiers of the institutions. {"T1": ["s1", "s2", "s5"], "t2": ["s2", "s7" , "S9"]}, "students": {"s1": ["T1", "T2"], "S2": ["T2", "T7"]}}
For example:
Warning ("Teachers are teachers of T1:" + Faculty. Taxers 1. Tosting ()); Warning ("Students are teachers of S2:" + faculty.stutants.to 2.toString ()); Warning ("Student S2 is the first teacher's student:" + faculty.Teckers [faculty.stutants.2 [0]] .toasting ());
Comments
Post a Comment