Example #1
0
        protected static double parseNumber(char[] json, ref int index)
        {
            MUJson.eatWhitespace(json, ref index);
            int lastIndexOfNumber = MUJson.getLastIndexOfNumber(json, index);
            int num = lastIndexOfNumber - index + 1;

            char[] array = new char[num];
            Array.Copy(json, index, array, 0, num);
            index = lastIndexOfNumber + 1;
            return(double.Parse(new string(array)));
        }
Example #2
0
        protected static string parseString(char[] json, ref int index)
        {
            string text = "";

            MUJson.eatWhitespace(json, ref index);
            char c    = json[index++];
            bool flag = false;

            while (!flag && index != json.Length)
            {
                c = json[index++];
                if (c == '"')
                {
                    flag = true;
                    break;
                }
                if (c == '\\')
                {
                    if (index == json.Length)
                    {
                        break;
                    }
                    c = json[index++];
                    if (c == '"')
                    {
                        text += '"';
                    }
                    else if (c == '\\')
                    {
                        text += '\\';
                    }
                    else if (c == '/')
                    {
                        text += '/';
                    }
                    else if (c == 'b')
                    {
                        text += '\b';
                    }
                    else if (c == 'f')
                    {
                        text += '\f';
                    }
                    else if (c == 'n')
                    {
                        text += '\n';
                    }
                    else if (c == 'r')
                    {
                        text += '\r';
                    }
                    else if (c == 't')
                    {
                        text += '\t';
                    }
                    else if (c == 'u')
                    {
                        int num = json.Length - index;
                        if (num < 4)
                        {
                            break;
                        }
                        char[] array = new char[4];
                        Array.Copy(json, index, array, 0, 4);
                        text   = text + "&#x" + new string(array) + ";";
                        index += 4;
                    }
                }
                else
                {
                    text += c;
                }
            }
            if (!flag)
            {
                return(null);
            }
            return(text);
        }
Example #3
0
        // Token: 0x0600016D RID: 365 RVA: 0x0000F86C File Offset: 0x0000DA6C
        protected static int nextToken(char[] json, ref int index)
        {
            MUJson.eatWhitespace(json, ref index);
            if (index == json.Length)
            {
                return(0);
            }
            char c = json[index];

            index++;
            char c2 = c;

            switch (c2)
            {
            case '"':
                return(7);

            case '#':
            case '$':
            case '%':
            case '&':
            case '\'':
            case '(':
            case ')':
            case '*':
            case '+':
            case '.':
            case '/':
                break;

            case ',':
                return(6);

            case '-':
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                return(8);

            case ':':
                return(5);

            default:
                switch (c2)
                {
                case '[':
                    return(3);

                case '\\':
                    break;

                case ']':
                    return(4);

                default:
                    switch (c2)
                    {
                    case '{':
                        return(1);

                    case '}':
                        return(2);
                    }
                    break;
                }
                break;
            }
            index--;
            int num = json.Length - index;

            if (num >= 5 && json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e')
            {
                index += 5;
                return(10);
            }
            if (num >= 4 && json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e')
            {
                index += 4;
                return(9);
            }
            if (num >= 4 && json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l')
            {
                index += 4;
                return(11);
            }
            return(0);
        }