Havunen / SystemTextJsonPatch

SystemTextJsonPatch is a JSON Patch (JsonPatchDocument) RFC 6902 implementation for .NET using System.Text.Json
MIT License
102 stars 12 forks source link

JsonPatchDocument converter doesn't respect other converters added to JsonSerializerOptions #24

Open hell-racer opened 1 year ago

hell-racer commented 1 year ago

Hi! We have string converter which trims string values and replaces empty strings with null. When JsonPatchDocumentConverter reads string values (specifically from value fields), it just uses val = reader.GetString(), so it ignores any string converters added to default JsonSerializerOptions. Is it possible to change value reading logic to just val = JsonSerializer.Deserialize<object>(ref reader); instead of this and this switch statements, to allow other converters to process values? Thanks!

hell-racer commented 11 months ago

So, what do you think? :)

Havunen commented 11 months ago

We need to measure how much it affects the performance and make sure it does not create infinite loops, otherwise sounds good to me

Havunen commented 11 months ago

One possibility is to bring this feature in as a new option

Havunen commented 1 week ago

This is challenging because imagine value is enum and the provided json value is string. It would be awesome if it could map that back to enum from the string, but in the operation model this information where the value will finally be used is not available easily

Havunen commented 1 week ago

PR is welcome, if somebody can make this work