示例#1
0
        public static TaskListModel.Rootobject DeseriliazeTaskListJson()
        {
            TaskListModel.Rootobject taskListModel = new TaskListModel.Rootobject();
            var json = System.IO.File.ReadAllText(@"D:\BB\GitHub\bozburak\ToDoList\ToDoList\DataSet\TaskList.json");

            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
            {
                DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(TaskListModel.Rootobject));
                taskListModel = (TaskListModel.Rootobject)deserializer.ReadObject(ms);
            }
            return(taskListModel);
        }
示例#2
0
        public static void SeriliazeAndUpdateTaskListJson(TaskListModel.Rootobject taskListModel)
        {
            string output = JsonConvert.SerializeObject(taskListModel);

            System.IO.File.WriteAllText(@"D:\BB\GitHub\bozburak\ToDoList\ToDoList\DataSet\TaskList.json", output);
        }