Example #1
0
        private static JsonObject ReadObject(JsonTextReader reader)
        {
            if (reader.Char != '{')
            {
                throw reader.ThrowFormat('{');
            }

            JsonObject result = new JsonObject();

            reader.ReadNext();
            reader.SkipWhiteSpace();

            if (reader.IsEOF)
            {
                throw reader.ThrowEOF('}');
            }
            else if (reader.Char != '}')
            {
                while (true)
                {
                    string key = reader.Dedublicate(ReadValueString(reader));

                    reader.SkipWhiteSpace();

                    if (reader.IsEOF)
                    {
                        throw reader.ThrowEOF(':');
                    }
                    else if (reader.Char != ':')
                    {
                        reader.ThrowFormat(':');
                    }

                    reader.ReadNext();
                    reader.SkipWhiteSpace();

                    result[key] = ReadValue(reader);
                    reader.SkipWhiteSpace();

                    if (reader.IsEOF)
                    {
                        throw reader.ThrowEOF('}');
                    }
                    else if (reader.Char == ',')
                    {
                        reader.ReadNext();
                        reader.SkipWhiteSpace();
                        continue;
                    }
                    else if (reader.Char == '}')
                    {
                        break;
                    }
                    else
                    {
                        reader.ThrowFormat(',', '}');
                    }
                }
            }

            reader.ReadNext();

            return(result);
        }