Exemple #1
0
        protected static object parseValue(char[] json, ref int index, ref bool success)
        {
            switch (MiniJSON.lookAhead(json, index))
            {
            case 1:
                return(MiniJSON.parseObject(json, ref index));

            case 3:
                return(MiniJSON.parseArray(json, ref index));

            case 7:
                return(MiniJSON.parseString(json, ref index));

            case 8:
                return(MiniJSON.parseNumber(json, ref index));

            case 9:
                MiniJSON.nextToken(json, ref index);
                return(bool.Parse("TRUE"));

            case 10:
                MiniJSON.nextToken(json, ref index);
                return(bool.Parse("FALSE"));

            case 11:
                MiniJSON.nextToken(json, ref index);
                return(null);
            }
            success = false;
            return(null);
        }
Exemple #2
0
        protected static Hashtable parseObject(char[] json, ref int index)
        {
            Hashtable hashtable = new Hashtable();

            MiniJSON.nextToken(json, ref index);
            bool flag = false;

            while (!flag)
            {
                int num = MiniJSON.lookAhead(json, index);
                if (num == 0)
                {
                    return(null);
                }
                if (num == 6)
                {
                    MiniJSON.nextToken(json, ref index);
                }
                else
                {
                    if (num == 2)
                    {
                        MiniJSON.nextToken(json, ref index);
                        return(hashtable);
                    }
                    string text = MiniJSON.parseString(json, ref index);
                    if (text == null)
                    {
                        return(null);
                    }
                    num = MiniJSON.nextToken(json, ref index);
                    if (num != 5)
                    {
                        return(null);
                    }
                    bool   flag2 = true;
                    object obj   = MiniJSON.parseValue(json, ref index, ref flag2);
                    if (!flag2)
                    {
                        return(null);
                    }
                    hashtable.set_Item(text, obj);
                }
            }
            return(hashtable);
        }
Exemple #3
0
        protected static ArrayList parseArray(char[] json, ref int index)
        {
            ArrayList arrayList = new ArrayList();

            MiniJSON.nextToken(json, ref index);
            bool flag = false;

            while (!flag)
            {
                int num = MiniJSON.lookAhead(json, index);
                if (num == 0)
                {
                    return(null);
                }
                if (num == 6)
                {
                    MiniJSON.nextToken(json, ref index);
                }
                else
                {
                    if (num == 4)
                    {
                        MiniJSON.nextToken(json, ref index);
                        break;
                    }
                    bool   flag2 = true;
                    object obj   = MiniJSON.parseValue(json, ref index, ref flag2);
                    if (!flag2)
                    {
                        return(null);
                    }
                    arrayList.Add(obj);
                }
            }
            return(arrayList);
        }
Exemple #4
0
        protected static int lookAhead(char[] json, int index)
        {
            int num = index;

            return(MiniJSON.nextToken(json, ref num));
        }