System.Runtime.Serialization.Json.JavaScriptReader.ReadCore C# (CSharp) Method

ReadCore() private method

private ReadCore ( ) : object
return object
        private object ReadCore()
        {
            SkipSpaces();
            int c = PeekChar();
            if (c < 0)
            {
                throw JsonError(SR.ArgumentException_IncompleteInput);
            }

            switch (c)
            {
                case '[':
                    ReadChar();
                    var list = new List<object>();
                    SkipSpaces();
                    if (PeekChar() == ']')
                    {
                        ReadChar();
                        return list;
                    }

                    while (true)
                    {
                        list.Add(ReadCore());
                        SkipSpaces();
                        c = PeekChar();
                        if (c != ',')
                            break;
                        ReadChar();
                        continue;
                    }

                    if (ReadChar() != ']')
                    {
                        throw JsonError(SR.ArgumentException_ArrayMustEndWithBracket);
                    }

                    return list.ToArray();

                case '{':
                    ReadChar();
                    var obj = new Dictionary<string, object>();
                    SkipSpaces();
                    if (PeekChar() == '}')
                    {
                        ReadChar();
                        return obj;
                    }

                    while (true)
                    {
                        SkipSpaces();
                        if (PeekChar() == '}')
                        {
                            ReadChar();
                            break;
                        }
                        string name = ReadStringLiteral();
                        SkipSpaces();
                        Expect(':');
                        SkipSpaces();
                        obj[name] = ReadCore(); // it does not reject duplicate names.
                        SkipSpaces();
                        c = ReadChar();
                        if (c == ',')
                        {
                            continue;
                        }
                        if (c == '}')
                        {
                            break;
                        }
                    }
                    return obj.ToArray();

                case 't':
                    Expect("true");
                    return true;

                case 'f':
                    Expect("false");
                    return false;

                case 'n':
                    Expect("null");
                    return null;

                case '"':
                    return ReadStringLiteral();

                default:
                    if ('0' <= c && c <= '9' || c == '-')
                    {
                        return ReadNumericLiteral();
                    }
                    throw JsonError(SR.Format(SR.ArgumentException_UnexpectedCharacter, (char)c));
            }
        }