.Net

The Confusing world of Text.Json and .Net 5

So one of the base libraries over the years that has been our friend is Newtonsoft.Json – the stuff of legend maybe? Well, if not, certainly anyone whose done .Net and used any kind of Json formatted data certainly knows of Newtonsoft.Json… The “go to Json Serializer”! That is until Microsoft set out to prove to the world they could do it better. Better?

Like many things in the world of .Net over the years, Microsoft watches these open source libraries… and notices when they become the defacto standard (meaning… Micro either left it out of their core offerings…. or more typical someone did better). Hence Microsoft’s System.Text.Json vs. NewtonSoft.Json.  Oh let the confusion begin!

Now to Microsoft’s credit they have been working to finally bring System.Text.Json up to speed… but of course they continue to state the their intent is not to bring their Json library up to par with Newtonsoft. And there it is… the two world Json library view… now mostly the complaint I have deals with migrating old code up to using Microsoft’s. It’s a bit of a “rub me the wrong way” kind of careful reading as to which direction to take. Why? Well you get into dependency  issues where Newtonsoft and Microsoft’s library don’t always play well together- that can be a problem when it comes to wanting to use old code (NewtonSoft) in a new app while wanting to take advantage of faster MS .Net 5 serializations….. Yeah, why would one ever want to do that?

Anyway, I take some time to read a great article @

[visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly9kZXZibG9ncy5taWNyb3NvZnQuY29tL2RvdG5ldC93aGF0cy1uZXh0LWZvci1zeXN0ZW0tdGV4dC1qc29uLyIsImltYWdlX2lkIjotMSwiaW1hZ2VfdXJsIjoiaHR0cHM6Ly9kZXZibG9ncy5taWNyb3NvZnQuY29tL2RvdG5ldC93cC1jb250ZW50L3VwbG9hZHMvc2l0ZXMvMTAvMjAyMC8xMC9kb3RuZXQtYm90LnBuZyIsInRpdGxlIjoiV2hhdOKAmXMgbmV4dCBmb3IgU3lzdGVtLlRleHQuSnNvbj8gfCAuTkVUIEJsb2ciLCJzdW1tYXJ5IjoiTGVhcm4gYWJvdXQgdGhlIG5ldyBwZXJmb3JtYW5jZSwgcmVsaWFpbGl0eSBhbmQgZWFzeSBhZG9wdGlvbiB0aGF0IGhhcyBiZWVuIG1hZGUgd2l0aCBTeXN0ZW0uVGV4dC5Kc29uLCBhbmQgd2hhdOKAmXMgZ29pbmcgdG8gY29tZSBuZXh0LiIsInRlbXBsYXRlIjoidXNlX2RlZmF1bHRfZnJvbV9zZXR0aW5ncyJ9″]

Layomi has a great write up of things to consider… especially in the section “Choosing between…” the two different libraries…. It’s a good read.

~SG

Leave a Reply