Support JSON parsing object to DateTimeOffset and preserve timezone offset in JsonObjectConverter
#16732
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
If there's an existing issue for this PR then this fixes #16587.
Description
Although I initially thought the CMS data type configuration migration (executed when upgrading v13 to v14) caused Deploy to write updated UDA files, it is actually due to the
JsonObjectConverter
(that's used by theIConfigurationEditorJsonSerializer
for reading and writing data type configuration) not correctly parsingDataTimeOffset
values.This custom JsonConverter takes care of deserializing JSON values into
object
instances to their simple/primitive types (boolean, integer, date or string), instead of a boxedJsonElement
(see https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-9-0#deserialization-of-object-properties). I assume this has been copied from the example in the Microsoft documentation, which clearly isn't really suitable to be used in production 🫤 Removing this converter would be a massive breaking change, as values will be parsed differently when deserializing, but I would suggest looking into thing for a future major release, as this also contains multiple performance issues (loading everything into lists, casting, creating generic types and new instances via reflection, etc.)...