Пример #1
0
            public static t1 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type
            {
                Biser.JsonDecoder decoder = null;

                if (extDecoder == null)
                {
                    if (enc == null || String.IsNullOrEmpty(enc))
                    {
                        return(null);
                    }
                    decoder = new Biser.JsonDecoder(enc, settings);
                    if (decoder.CheckNull())
                    {
                        return(null);
                    }
                }
                else
                {
                    //JSONSettings of the existing decoder will be used
                    decoder = extDecoder;
                }

                t1 m = new t1();  //!!!!!!!!!!!!!! change return type

                foreach (var props in decoder.GetDictionary <string>())
                {
                    switch (props)
                    {
                    case "p1":
                        m.p1 = decoder.GetInt();
                        break;

                    case "p2":
                        m.p2 = decoder.GetString();
                        break;

                    case "p3":
                        m.p3 = t2.BiserJsonDecode(null, decoder);
                        break;

                    case "p4":
                        m.p4 = decoder.CheckNull() ? null : new List <t2>();
                        if (m.p4 != null)
                        {
                            foreach (var el in decoder.GetList())
                            {
                                m.p4.Add(t2.BiserJsonDecode(null, decoder));
                            }
                        }
                        break;

                    default:
                        decoder.SkipValue();    //MUST BE HERE
                        break;
                    }
                }
                return(m);
            }
Пример #2
0
            public static t2 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type
            {
                Biser.JsonDecoder decoder = null;

                if (extDecoder == null)
                {
                    if (enc == null || String.IsNullOrEmpty(enc))
                    {
                        return(null);
                    }
                    decoder = new Biser.JsonDecoder(enc, settings);
                    if (decoder.CheckNull())
                    {
                        return(null);
                    }
                }
                else
                {
                    //JSONSettings of the existing decoder will be used
                    decoder = extDecoder;
                }

                t2 m = new t2();  //!!!!!!!!!!!!!! change return type

                foreach (var props in decoder.GetDictionary <string>())
                {
                    switch (props)
                    {
                    case "p1":
                        m.p1 = decoder.GetDateTime();
                        break;

                    case "p2":
                        m.p2 = decoder.GetString();
                        break;

                    default:
                        decoder.SkipValue();    //MUST BE HERE
                        break;
                    }
                }
                return(m);
            }