BO4E/meta/LenientConverters/LenientDictionaryConverter.cs
/// <summary>
///     Read the Dicitionary from a JSON reader
/// </summary>
/// <param name="reader">the json reader passed by the converter</param>
/// <param name="typeToConvert">The type we want to construct</param>
/// <param name="options">any json serializer options</param>
/// <returns></returns>
Read the Dicitionary from a JSON reader
Read the Dicitionary from a JSON reader
public override Dictionary<string, object> Read(ref Utf8JsonReader reader, Type typeToConvert,
            JsonSerializerOptions options)
        {
            if (reader.TokenType != JsonTokenType.StartObject)
                throw new JsonException($"JsonTokenType was of type {reader.TokenType}, only objects are supported");
            var dictionary = new Dictionary<string, object>();
            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject) return dictionary;
                if (reader.TokenType != JsonTokenType.PropertyName)
                    throw new JsonException("JsonTokenType was not PropertyName");
                var propertyName = reader.GetString();
                if (string.IsNullOrWhiteSpace(propertyName)) throw new JsonException("Failed to get property name");
                reader.Read();
                dictionary.Add(propertyName, ExtractValue(ref reader, options));
            }
            return dictionary;
        }
public override Dictionary < string , object > Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options ) { if ( reader . TokenType != JsonTokenType . StartObject ) throw new JsonException ( $" JsonTokenType was of type  { reader . TokenType } , only objects are supported " ) ; var dictionary = new Dictionary < string , object > ( ) ; while ( reader . Read ( ) ) { if ( reader . TokenType == JsonTokenType . EndObject ) return dictionary ; if ( reader . TokenType != JsonTokenType . PropertyName ) throw new JsonException ( " " ) ; var propertyName = reader . GetString ( ) ; if ( string . IsNullOrWhiteSpace ( propertyName ) ) throw new JsonException ( " " ) ; reader . Read ( ) ; dictionary . Add ( propertyName , ExtractValue ( ref reader , options ) ) ; } return dictionary ; }
Read the Dicitionary from a JSON reader
Read the Dicitionary from a JSON reader
None
Utf8JsonReader
ref
<not_specific>
typeToConvert
Type
The type we want to construct
The type we want to construct
options
JsonSerializerOptions
any json serializer options
any json serializer options
reader
<not_specific>
the json reader passed by the converter
the json reader passed by the converter