Example #1
0
 public void Put(string name, JArr v)
 {
     if (counts[level]++ > 0)
     {
         Add(',');
     }
     if (name != null)
     {
         Add('"');
         Add(name);
         Add('"');
         Add(':');
     }
     if (v == null)
     {
         Add("null");
     }
     else
     {
         counts[++level] = 0; // enter
         Add('[');
         v.Write(this);
         Add(']');
         level--; // exit
     }
 }
Example #2
0
 public JMbr(JArr v, string name = null)
 {
     this.name = name;
     typ       = JType.Array;
     refv      = v;
     numv      = default;
 }
Example #3
0
        public bool Get(string name, ref JArr v)
        {
            if (TryGetValue(name, out var mbr))
            {
                v = mbr;
                return(true);
            }

            return(false);
        }
Example #4
0
        public bool Get(string name, ref string[] v)
        {
            if (TryGetValue(name, out var mbr))
            {
                JArr ja = mbr;
                if (ja != null)
                {
                    v = new string[ja.Count];
                    for (int i = 0; i < ja.Count; i++)
                    {
                        v[i] = ja[i];
                    }
                }

                return(true);
            }

            return(false);
        }
Example #5
0
        public bool Get <D>(string name, ref D[] v, short msk = 0xff) where D : IData, new()
        {
            if (TryGetValue(name, out var mbr))
            {
                JArr ja = mbr;
                if (ja != null)
                {
                    v = new D[ja.Count];
                    for (int i = 0; i < ja.Count; i++)
                    {
                        JObj jo  = ja[i];
                        D    dat = new D();
                        dat.Read(jo);
                        v[i] = dat;
                    }
                }

                return(true);
            }

            return(false);
        }
Example #6
0
 public bool Get(string name, ref JArr v)
 {
     return(false);
 }
Example #7
0
 public void Put(string name, JArr v)
 {
 }
Example #8
0
 public void Add(JArr el)
 {
     Add(new JMbr(el));
 }
Example #9
0
 public bool Get(string name, ref JArr v)
 {
     throw new NotImplementedException();
 }
Example #10
0
        public static D[] StringToArray <D>(string v, short proj = 0xff) where D : IData, new()
        {
            JArr ja = (JArr) new JsonParser(v).Parse();

            return(ja.ToArray <D>(proj));
        }
Example #11
0
 public void Add(string name, JArr v)
 {
     Add <JMbr>(new JMbr(v, name));
 }