Example #1
0
            public void Scan(MyJson.ScanObj scan)
            {
                StringBuilder sb = new StringBuilder();

                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();
            }
Example #2
0
            public void Scan(MyJson.ScanObj scan)
            {
                StringBuilder 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      = new StringBuilder();
                        }
                    }
                    else if (keystate == 1)
                    {
                        if (c == '\"')
                        {
                            keystate = 2;
                            continue;
                        }
                        else
                        {
                            key.Append(c);
                        }
                    }
                    else
                    {
                        IJsonNode node = MyJson.ScanFirst(c);
                        if (node != null)
                        {
                            scan.seed = i;
                            node.Scan(scan);
                            i = scan.seed - 1;
                            this.Add(key.ToString(), node);
                            keystate = 0;
                        }
                    }
                }
            }
Example #3
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;
                }
            }
Example #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);
         }
     }
 }