Other Serialization technologies include Binary and XML Serialization.
System.Text.Json
New hotness <3
1 | public string ToJson(object obj) |
Json Serializer Options
1 | public static JsonSerializerOptions IgnoreDefaultValues { get; } = new JsonSerializerOptions |
Json.NET / Newtonsoft Framework
Was integrated into ASP.NET even though it was 3rd party, I think its called Middleware. This lib is pretty much the de facto standard for JSON Serialization (Probably won awards, free beer & stuff!)
1 | public string ToJson(object obj) |
- https://github.com/carlpaton/Common/blob/master/Common/Serialization/JsonConvertService.cs
- https://www.newtonsoft.com/json
System.Runtime.Serialization.Json
Class: DataContractJsonSerializer
An older, Microsoft-developed serializer that was integrated in previous ASP.NET versions until Newtonsoft.Json replaced it. Needs more code and sucks, don’t use it :D
1 | public string ToJson<T>(object obj) |
- https://github.com/carlpaton/Common/blob/master/Common/Serialization/DataContractJsonSerializerService.cs
- https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-serialize-and-deserialize-json-data
- https://www.c-sharpcorner.com/article/json-serialization-and-deserialization-in-c-sharp/
System.Web.Script.Serialization
I remember using this ages ago in Web Forms
and AjaxServer.asmx.cs
files - I stopped using it after somebody showed me Json.NET
1 | var list = new List<string>(); |