c# - Converting Flat data to hierarchical -
i getting flat data in c# application list. sample data google drive spreadsheet
i want data converted hierarchical structure. have created json representation of same here
the final structure expecting here
i have created data list in c#. want list converted c# collection object. please give me pointers on easiest way so. [this console application code]
using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication1 { class program { public class marklist { public string student_name { set; get; } public string frequency { set; get; } public string major { set; get; } public string subject_category { set; get; } public string subject_subcategory { set; get; } public int spring_mark { set; get; } public int autumn_mark { set; get; } public int summer_mark { set; get; } public marklist() { } public marklist(string student_name,string frequency,string major,string subject_category,string subject_subcategory,string spring_mark,string autumn_mark,string summer_mark) { student_name =student_name; frequency =frequency; major =major; subject_category =subject_category; subject_subcategory =subject_subcategory; spring_mark =spring_mark; autumn_mark =autumn_mark; summer_mark =summer_mark; } } static void main(string[] args) { list<marklist> marklists = new list<marklist>(); marklists.add(new marklist(){student_name="nimalan",frequency="monthly",major="science",subject_category="physics",subject_subcategory="atomic",spring_mark=100,autumn_mark=95,summer_mark=75}); marklists.add(new marklist(){student_name="nimalan",frequency="monthly",major="science", subject_category="physics",subject_subcategory="nuclear",spring_mark=95, autumn_mark=75,summer_mark=100}); marklists.add(new marklist(){student_name="nimalan",frequency="monthly",major="science", subject_category="physics",subject_subcategory="electronics",spring_mark=75, autumn_mark=95,summer_mark=100}); marklists.add(new marklist(){student_name="nimalan",frequency="monthly",major="language", subject_category="tamil",subject_subcategory="literature",spring_mark=80, autumn_mark=90,summer_mark=70}); marklists.add(new marklist(){student_name="nimalan",frequency="monthly",major="commerce" subject_category="retail_data",subject_subcategory="big_data_analytics",spring_mark=90, autumn_mark=80,summer_mark=70}); marklists.add(new marklist(){student_name="nimalan",frequency="weekly",major="science",subject_category="physics",subject_subcategory="atomic",spring_mark=100,autumn_mark=95,summer_mark=75}); marklists.add(new marklist(){student_name="nimalan",frequency="weekly",major="science", subject_category="physics",subject_subcategory="nuclear",spring_mark=95, autumn_mark=75,summer_mark=100}); marklists.add(new marklist(){student_name="nimalan",frequency="weekly",major="science", subject_category="physics",subject_subcategory="electronics",spring_mark=75, autumn_mark=95,summer_mark=100}); marklists.add(new marklist(){student_name="nimalan",frequency="weekly",major="language", subject_category="tamil",subject_subcategory="literature",spring_mark=80, autumn_mark=90,summer_mark=70}); marklists.add(new marklist(){student_name="nimalan",frequency="weekly",major="commerce" subject_category="retail_data",subject_subcategory="big_data_analytics",spring_mark=90, autumn_mark=80,summer_mark=70}); marklists.add(new marklist(){student_name="starnimalan",frequency="monthly",major="science",subject_category="physics",subject_subcategory="atomic",spring_mark=100,autumn_mark=95,summer_mark=75}); marklists.add(new marklist(){student_name="starnimalan",frequency="monthly",major="science", subject_category="physics",subject_subcategory="nuclear",spring_mark=95, autumn_mark=75,summer_mark=100}); marklists.add(new marklist(){student_name="starnimalan",frequency="monthly",major="science", subject_category="physics",subject_subcategory="electronics",spring_mark=75, autumn_mark=95,summer_mark=100}); marklists.add(new marklist(){student_name="starnimalan",frequency="monthly",major="language", subject_category="tamil",subject_subcategory="literature",spring_mark=80, autumn_mark=90,summer_mark=70}); marklists.add(new marklist(){student_name="starnimalan",frequency="monthly",major="commerce" subject_category="retail_data",subject_subcategory="big_data_analytics",spring_mark=90, autumn_mark=80,summer_mark=70}); } } }
use class created json data using jsonc# http://json2csharp.com/#
public class mark { public string markname { get; set; } public int mark { get; set; } } public class subjectsubcategory { public string name { get; set; } public list<mark> marks { get; set; } } public class subjectcategory { public string name { get; set; } public list<subjectsubcategory> subject_subcategory { get; set; } } public class major { public string name { get; set; } public list<subjectcategory> subject_category { get; set; } } public class frequency { public string name { get; set; } public list<major> major { get; set; } } public class product { public string studentname { get; set; } public list<frequency> frequency { get; set; } } public class rootobject { public list<product> product { get; set; } }
Comments
Post a Comment