DynamicRest.JsonReader.ReadObject C# (CSharp) Method

ReadObject() private method

private ReadObject ( ) : JsonObject
return JsonObject
        private JsonObject ReadObject()
        {
            JsonObject record = new JsonObject();
            IDictionary<string, object> recordItems = (IDictionary<string, object>)record;

            // Consume the '{'
            _reader.Read();

            while (true) {
                char ch = PeekNextSignificantCharacter();
                if (ch == '\0') {
                    throw new FormatException("Unterminated object literal.");
                }

                if (ch == '}') {
                    _reader.Read();
                    return record;
                }

                if (recordItems.Count != 0) {
                    if (ch != ',') {
                        throw new FormatException("Invalid object literal.");
                    }
                    else {
                        _reader.Read();
                    }
                }

                string name = ReadName(/* allowQuotes */ true);
                ch = PeekNextSignificantCharacter();

                if (ch != ':') {
                    throw new FormatException("Unexpected name/value pair syntax in object literal.");
                }
                else {
                    _reader.Read();
                }

                object item = ReadValue();
                recordItems[name] = item;
            }
        }