public UserVO deserializeToUser (string response){ IDictionary search = Json.Deserialize(response) as IDictionary; UserVO user = new UserVO(); foreach (var key in search.Keys){ IDictionary temp =(IDictionary) search[key]; user.key = key.ToString(); user.username = temp["username"].ToString(); user.email = temp["email"].ToString(); user.password = temp["password"].ToString(); user.isTeacher = (bool)temp["isTeacher"]; List<object> sbj = temp["subjects"] as List<object>; List<string> subjects = new List<string>(); foreach(var item in sbj) { subjects.Add(item.ToString()); } user.subjects = subjects; user.status = false; } return user; }
public IEnumerator GetUserGroups (UserVO user) { CoroutineWithData cd = new CoroutineWithData(this, GetUserSubjects(user.subjects)); yield return cd.coroutine; IList<SubjectVO> user_subjects = cd.result as List<SubjectVO>; IList<GroupVO> user_groups = new List<GroupVO>(); foreach (var subject in user_subjects) { string url = "group/" + subject.group_id + ".json"; Debug.Log ("Groups url: " + url); CoroutineWithData cd1 = new CoroutineWithData(this, myFirebase.GET(url)); yield return cd1.coroutine; GroupVO group = customDeserializer.deserializeToGroup(cd1.result.ToString()); group.key = subject.group_id; user_groups.Add(group); } Debug.Log("Carla is in: " + user_groups[0].name); yield return user_groups; }