Unable to deserialize ArraySegment<int> with System.Text.Json.JsonSerializer.Deserialize #107783
Labels
area-System.Text.Json
enhancement
Product code improvement that does NOT require public API changes/additions
Milestone
Description
Unable to deserialize
ArraySegment<int>
usingSystem.Text.Json.JsonSerializer
, even when the value was serialized usingSystem.Text.Json.JsonSerializer
.Reproduction Steps
Use XUnit test below:
Expected behavior
The
System.Text.Json.JsonSerializer
should be able to successfully deserialize anArraySegment<int>
object that was serialized using the same or other serializer, without any errors or data loss.Actual behavior
When attempting to deserialize an
ArraySegment<int>
object usingSystem.Text.Json.JsonSerializer
, aNotSupportedException
is thrown, indicating that deserialization is not supported for this type, despite it being serialized with the same serializer.Regression?
No response
Known Workarounds
As a workaround, you can use
Newtonsoft.Json.JsonConvert
for both serialization and deserialization ofArraySegment<int>
.JsonConvert
handles this type without throwing exceptions, providing a seamless serialization/deserialization process.Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: