https://devblogs.microsoft.com/dotnet/whats-next-for-system-text-json/
I hate what Microsoft did with their Json library. It looks like a half-assed unfinished clone of Newtonsoft.Json. I wasted couple of days porting my data classes from Newtonsoft to System.Text.Json only to find out that half of stuff is not yet available in the new library. Why didn’t they just try to improve Newtonsoft.Json instead of building their own clone?
Why didn’t they just try to improve Newtonsoft.Json
The author said explained this, the main reason for writing something new was to make something more performant by using new features such as Spans. It would involve changing fundamental things from the parsing level up, which would be impossible to make backwards compatible with the existing version.
It’s just easier to get rid of legacy and rebuild it from the ground up and now as part of the framework. It’s not weird that System.Text.Json has less features, Newtonsoft.Json evolved over many years, System.Text.Json is simply very young
Out of interest, what are the main things you’re missing?
I’ve recently started a personal project in .Net 5.0 using System.Text.Json. Haven’t run into any issues so far, but it’s all been simple usages. Would be good to know where the limitations are.
You realize you can keep using JSON.NET right? The reason for introducing the new library was of course performance.
half of stuff is not yet available in the new library
Like what?
As far as I know they were looking for a faster library that used the latest language/framework features, so by missing stuff you mean high level apis? Because I managed to do everything I needed but of course, with a lot of WriteObjectStart and such, which it’s kind of a pain but it’s not like it’s impossible to achieve.
I feel like they wanted to have json lib with way better performance.
I still do use Newtonsoft because it handles things as I do expect, instead of what’s “proper” by standard or something along these lines.
Sometimes you have to make fundamentally different trade offs/decisions to get target performance. Maybe better to leave Newtonsoft alone and make a new option. You don’t have to use it.
It looks like a half-assed unfinished clone of Newtonsoft.Json.
That’s because it is. They literally state in the article that it was written because it became impractical for them to keep shipping NS.Json because their release cadence was so much slower (and therefore, anyone using ASP.NET either risks instability or getting stuck with an old version of NS.Json).
It began with the goal to implement the features/perf needed by ASP.NET – anything else is lower priority. I’m happy that they built it, but honestly I don’t understand why anybody outside of Microsoft wants to use it. NS.Json has more flexibility and features and there are other, faster JSON serialization libraries if you really need speed.
Finally, support for immutable classes! Well, would have been weird to continue to not support it when they added support for records.
Not really, since records are actually not immutable at runtime.
Someone please tell Microsoft: “It’s in the wrong namespace!”
Just hope I can replace Newtonsoft in Nswag soon
It will have selection of Newtonsoft, System.Json 3.0, and 5.0 at first.
Or it may just stay on Newtonsoft until EOL.
C# devs
null reference exceptions