NET 8 – Serialization of Half, Int128, and UInt128
System.Text.Json
brings out of the box support for additional types:
Let’s look at an example:
Console.WriteLine(JsonSerializer.Serialize(Half.MaxValue));
// Output: 65500
Console.WriteLine(JsonSerializer.Serialize(Int128.MaxValue));
// Output: 170141183460469231731687303715884105727
Console.WriteLine(JsonSerializer.Serialize(UInt128.MaxValue));
// Output: 340282366920938463463374607431768211455
Code language: C# (cs)