protected static Object DeserializeUnknownObject(JsonReader reader) { Guard.NotNull(reader, nameof(reader)); if (reader.TokenType == JsonToken.PropertyName) { reader.Read(); } if (reader.TokenType == JsonToken.StartArray) { var list = new JsonList(); while (reader.Read() && reader.TokenType != JsonToken.EndArray) { list.Add(DeserializeUnknownObject(reader)); } return(list); } if (reader.TokenType == JsonToken.StartObject) { var dict = new JsonDictionary(); while (reader.Read() && reader.TokenType != JsonToken.EndObject) { if (reader.TokenType == JsonToken.PropertyName) { var key = reader.Value as String; dict[key] = DeserializeUnknownObject(reader); } else { throw new JsonReaderException(); } } return(dict); } System.Diagnostics.Debug.Assert(reader.TokenType != JsonToken.None); System.Diagnostics.Debug.Assert(reader.TokenType != JsonToken.EndArray); System.Diagnostics.Debug.Assert(reader.TokenType != JsonToken.EndObject); System.Diagnostics.Debug.Assert(reader.TokenType != JsonToken.EndConstructor); return(reader.Value); }
protected static Object DeserializeUnknownObject(ref Utf8JsonReader reader) { if (reader.TokenType == JSONTOKEN.PropertyName) { reader.Read(); } if (reader.TokenType == JSONTOKEN.StartArray) { var list = new JsonList(); while (reader.Read() && reader.TokenType != JSONTOKEN.EndArray) { list.Add(DeserializeUnknownObject(ref reader)); } return(list); } if (reader.TokenType == JSONTOKEN.StartObject) { var dict = new JsonDictionary(); while (reader.Read() && reader.TokenType != JSONTOKEN.EndObject) { if (reader.TokenType == JSONTOKEN.PropertyName) { var key = reader.GetString(); dict[key] = DeserializeUnknownObject(ref reader); } else { throw new JSONEXCEPTION(); } } return(dict); } System.Diagnostics.Debug.Assert(reader.TokenType != JSONTOKEN.None); System.Diagnostics.Debug.Assert(reader.TokenType != JSONTOKEN.EndArray); System.Diagnostics.Debug.Assert(reader.TokenType != JSONTOKEN.EndObject); // System.Diagnostics.Debug.Assert(reader.TokenType != JsonToken.EndConstructor); return(reader.GetAnyValue()); }