Categories Dotnet6
Retweets are appreciated ☺️
#dotnet6 #coding #devcommunity #json #programming
Ignore circular
In .NET 5, you can preserve references for circular references using System.Text.Json.
— Oleg Kyrylchuk (@okyrylchuk) October 6, 2021
But you couldn't ignore them. The 'JsonException' is thrown if circular references have been detected.
In .NET 6, you can ignore them \U0001f642#dotnet6 #json #coding #devcommunity pic.twitter.com/FnvR8gjwvN
Notifications for
In .NET 6, System.Text.Json exposes notifications for (de)serialization.
— Oleg Kyrylchuk (@okyrylchuk) October 7, 2021
There are four new interfaces to implement according to your needs:
\u2022 IJsonOnDeserialized
\u2022 IJsonOnDeserializing
\u2022 IJsonOnSerialized
\u2022 IJsonOnSerializing#dotnet6 #json #coding #devcommunity pic.twitter.com/iYpzHsg8Hy
Serialization order of
In .NET 6, the 'JsonPropertyOrderAttribute' has been added to System.Text.Json.
— Oleg Kyrylchuk (@okyrylchuk) October 8, 2021
It allows controlling the serialization order of properties.
Previously, the serialization order was determined by reflection order.#dotnet6 #json #coding #devcommunity pic.twitter.com/5sBJRWOvcX
Write raw JSON with
.NET 6 introduces the possibility to write 'raw' #json with System.Text.Json.Utf8JsonWriter.
— Oleg Kyrylchuk (@okyrylchuk) October 16, 2021
Useful when you want:
\u2022 to enclose existing JSON in new JSON
\u2022 to format values differently from the default formatting#dotnet6 #coding #devcommunity pic.twitter.com/NguR3wEOAM