How to build object hierarchy for serialization with json.net?

后端 未结 3 778
醉梦人生
醉梦人生 2020-12-24 02:30

I\'m trying to properly write code to build a data structure to serialize into json.

I\'m using json.net.

I don\'t want to create a bunch of classes to hold

3条回答
  •  悲哀的现实
    2020-12-24 03:16

    In the end I have used these Models.

    public class JStudent
    {
        public List projects = new List();
        public string name;
        public string id;
    }
    public class JProject
    {
        public List tasks = new List();
        public string name;
        public string id;
    }
    public class JTask
    {
        public string name;
        public string id;
    
    }
    

    It is now working perfectly. Is there any better way to do this?

提交回复
热议问题