Esempio 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;
        }
Esempio n. 2
0
        public void Scan(MyJson.ScanObj scan)
        {
            StringBuilder sb = new StringBuilder();

            //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];
                    sb.Append(c);
                }

                else if (c != '\"')
                {
                    sb.Append(c);
                }

                else
                {
                    scan.seed = i + 1;
                    break;
                }
            }
            value = sb.ToString();
        }
Esempio n. 3
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;
                    }
                }
            }
        }
Esempio n. 4
0
        public void Scan(MyJson.ScanObj scan)
        {
            StringBuilder sb = new StringBuilder();

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

            if (number == "true")
            {
                value  = 1;
                isBool = true;
            }
            else if (number == "false")
            {
                value  = 0;
                isBool = true;
            }
            else if (number == "null")
            {
                value  = 0;
                isNull = true;
            }
            else
            {
                value  = double.Parse(number);
                isBool = false;
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
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);
                }

            }
        }