Exemplo n.º 1
0
            public void Scan(MyJson.ScanObj scan)
            {
                string _value = "";

                for (int i = scan.seed + 1; i < scan.json.Length; i++)
                {
                    char c = scan.json[i];
                    if (c == '\\')
                    {
                        i++;
                        c       = scan.json[i];
                        _value += c;
                    }

                    else if (c != '\"')
                    {
                        _value += c;
                    }

                    else
                    {
                        scan.seed = i + 1;
                        break;
                    }
                }
                value = _value;
            }
Exemplo n.º 2
0
            //public MyJson.IJsonNode  this[string key]
            //{
            //    get
            //    {
            //        if (this.ContainsKey(key))
            //        {
            //            return base[key];
            //        }

            //        throw new Exception("key not exist");

            //    }
            //    set
            //    {
            //        if (value == null)
            //        {

            //            throw new Exception("value is null. key:"+key);
            //        }
            //        base[key] = value;
            //    }
            //}

            public void Scan(MyJson.ScanObj scan)
            {
                string key      = null;
                int    keystate = 0;//0 nokey 1scankey 2gotkey

                for (int i = scan.seed + 1; i < scan.json.Length; i++)
                {
                    char c = scan.json[i];
                    if (keystate != 1 && (c == ',' || c == ':'))
                    {
                        continue;
                    }
                    if (c == '}')
                    {
                        scan.seed = i + 1;
                        break;
                    }
                    if (keystate == 0)
                    {
                        if (c == '\"')
                        {
                            keystate = 1;
                            key      = "";
                        }
                    }
                    else if (keystate == 1)
                    {
                        if (c == '\"')
                        {
                            keystate = 2;
                            //scan.seed = i + 1;
                            continue;
                        }
                        else
                        {
                            key += c;
                        }
                    }
                    else
                    {
                        IJsonNode node = MyJson.ScanFirst(c);
                        if (node != null)
                        {
                            scan.seed = i;
                            node.Scan(scan);
                            i = scan.seed - 1;
                            this.Add(key, node);
                            keystate = 0;
                        }
                    }
                }
            }
Exemplo n.º 3
0
            public void Scan(MyJson.ScanObj scan)
            {
                string number = "";

                for (int i = scan.seed; i < scan.json.Length; i++)
                {
                    char c = scan.json[i];
                    if (c != ',' && c != ']' && c != '}' && c != ' ')
                    {
                        if (c != '\n')
                        {
                            number += c;
                        }
                    }
                    else
                    {
                        scan.seed = i;
                        break;
                    }
                }

                if (number.ToLower() == "true")
                {
                    value  = 1;
                    isBool = true;
                }
                else if (number.ToLower() == "false")
                {
                    value  = 0;
                    isBool = true;
                }
                else if (number.ToLower() == "null")
                {
                    value  = 0;
                    isNull = true;
                }
                else
                {
                    value  = double.Parse(number);
                    isBool = false;
                }
            }
Exemplo n.º 4
0
 public void Scan(MyJson.ScanObj scan)
 {
     for (int i = scan.seed + 1; i < scan.json.Length; i++)
     {
         char c = scan.json[i];
         if (c == ',')
         {
             continue;
         }
         if (c == ']')
         {
             scan.seed = i + 1;
             break;
         }
         IJsonNode node = MyJson.ScanFirst(c);
         if (node != null)
         {
             scan.seed = i;
             node.Scan(scan);
             i = scan.seed - 1;
             this.Add(node);
         }
     }
 }