You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JsonConverter for {ReadOnly}Memory doesn't deserialize nulls #95267
Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to System.ReadOnlyMemory`1[System.Single]. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
I believe so, yes. Just FWIW, readonly struct ImmutableArray<T> also throws this exception, but I believe ImmutableArray<T> doesn't have any bonds with null as opposed to this one. I'm not aware of any more "struct collections" to use as a reference for the semantic.
Activity
eiriktsarpalis commentedon Nov 27, 2023
cc @jozkee, do you think we should try change this to support
nullJSON tokens?jozkee commentedon Nov 27, 2023
I believe so, yes. Just FWIW,
readonly struct ImmutableArray<T>also throws this exception, but I believeImmutableArray<T>doesn't have any bonds with null as opposed to this one. I'm not aware of any more "struct collections" to use as a reference for the semantic.