Skip to content

Default Json options: NumberHandling #2022

@jods4

Description

@jods4

Most users would expect the default JSON serialization to match ASP.NET default serialization.

I suggest that GetDefaultJsonSerializerOptions() here: https://github.com/reactiveui/refit/blob/main/Refit/SystemTextJsonContentSerializer.cs#L64-L78 should be based on JsonSerializerOptions.Web in .NET 9+, or equivalent options in lower runtimes.

The key difference (besides the converters added by Refit) is NumberHandling.
Default web serializer sets NumberHandling = JsonNumberHandling.AllowReadingFromString.

The consequence of this change is that deserialization into numbers would be possible from strings, which should not be a breaking change.
It's not uncommon to serialize numbers into strings when using numbers larger than doubles, or decimal types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions