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);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            SomeClass sc = Serializator.ReadToObject("{\"key1\":\"value1\", \"key2\":[\"arrayValue1\", \"arrayValue2\", \"arrayValue3\"]}");

            foreach (var item in sc.key2)
            {
                Console.WriteLine(item);
            }
        }
        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);
        }
        static void Main(string[] args)
        {
            CombinedClass     cb = new CombinedClass();
            IntermediateClass ic = (IntermediateClass)Serializator.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));

            cb.group = new List <GroupClass>();
            foreach (var item in ic.group)
            {
                cb.group.Add((GroupClass)Serializator.ReadToObject(item, typeof(GroupClass)));
            }
            cb.error = (ErrorClass)Serializator.ReadToObject(ic.error, typeof(ErrorClass));
            Console.WriteLine(cb.error.ErrorCode);
            Console.WriteLine(cb.error.ErrorMessage);
            Console.WriteLine(cb.group[0].Name);
            Console.WriteLine(cb.group[0].ID);
            Console.WriteLine(cb.group[1].Name);
            Console.WriteLine(cb.group[1].ID);
        }