static void Main(string[] args) { Serializator ser = new Serializator(); IntermediateClass ic = (IntermediateClass)ser.ReadToObject("{\"error\":\"{\\n \\\"ErrorCode\\\" : 0,\\n \\\"ErrorMessage\\\" : \\\"Success.\\\"\\n}\\n\",\"group\":[\"{\\n \\\"ID\\\" : 1,\\n \\\"Name\\\" : \\\"Student1\\\"\\n}\\n\",\"{\\n \\\"ID\\\" : 2,\\n \\\"Name\\\" : \\\"Student2\\\"\\n}\\n\"]}", typeof(IntermediateClass)); ErrorClass ec = (ErrorClass)ser.ReadToObject(ic.error, typeof(ErrorClass)); Console.WriteLine(ec.ErrorCode); Console.WriteLine(ec.ErrorMessage); }
static void Main(string[] args) { Serializator ser = new Serializator(); IntermediateClass ic = (IntermediateClass)ser.ReadToObject("{\"error\":\"{\\n \\\"ErrorCode\\\" : 0,\\n \\\"ErrorMessage\\\" : \\\"Success.\\\"\\n}\\n\",\"group\":[\"{\\n \\\"ID\\\" : 1,\\n \\\"Name\\\" : \\\"Student1\\\"\\n}\\n\",\"{\\n \\\"ID\\\" : 2,\\n \\\"Name\\\" : \\\"Student2\\\"\\n}\\n\"]}", typeof(IntermediateClass)); List <GroupClass> gc = new List <GroupClass>(); foreach (var item in ic.group) { gc.Add((GroupClass)ser.ReadToObject(item, typeof(GroupClass))); } ErrorClass ec = (ErrorClass)ser.ReadToObject(ic.error, typeof(ErrorClass)); Console.WriteLine(ec.ErrorCode); Console.WriteLine(ec.ErrorMessage); Console.WriteLine(gc[0].Name); Console.WriteLine(gc[1].Name); }