Most active commenters

    ←back to thread

    .NET 10

    (devblogs.microsoft.com)
    489 points runesoerensen | 16 comments | | HN request time: 1.032s | source | bottom
    1. kurokawad ◴[] No.45898241[source]
    To me, it's pretty much unbelievable that Microsoft introduces an agent framework while for JSON serializing third-party Newtonsoft is still the go-to.

    Edit. I was not aware that the gap between System.Text.Json and Newtonsoft narrowed, take my comment with a grain of salt, please!

    replies(5): >>45898252 #>>45898257 #>>45898281 #>>45899376 #>>45904557 #
    2. vintermann ◴[] No.45898252[source]
    What's wrong with System.Text.Json?
    replies(1): >>45901281 #
    3. Deukhoofd ◴[] No.45898257[source]
    Is it? We've switched over to System.Text.Json entirely.
    4. monerofglory ◴[] No.45898281[source]
    The go-to nowadays is System.Text.Json, developed by the same person as Newtonsoft.Json, built in to .NET.

    Newtonsoft.Json as the primary JSON serializer (at least in every place I've worked) has NOT been the case versus System.Text.Json for years. Though it certainly used to be the case.

    replies(2): >>45898298 #>>45902502 #
    5. kurokawad ◴[] No.45898298[source]
    Uh okay! I was not aware of this. Thanks for pointing that out. Why is there so much difference in the NuGet downloads between both libraries tho?
    replies(4): >>45898424 #>>45898540 #>>45898548 #>>45905845 #
    6. Hawxy ◴[] No.45898424{3}[source]
    > Why is there so much difference in the NuGet downloads between both libraries tho?

    Because there's a boatload of older .NET apps that have been using Newtonsoft for over a decade already and aren't in a rush to switch. Anything built on .NET Framework is likely to still use Newtonsoft.

    7. akoeplinger ◴[] No.45898540{3}[source]
    System.Text.Json ships as part of the shared framework in recent versions of .NET so for most users it won't be restored from nuget.org
    8. xnorswap ◴[] No.45898548{3}[source]
    System.Text.Json isn't needed as a nuget library for newer development, the library is only needed for older stuff.

    Those older stuff are likely running newtonsoft.Json anyway.

    There's also a load of .NET Framework applications still running Newstonsoft.

    9. BatteryMountain ◴[] No.45899376[source]
    Haven't touched the newtonsoft package since .net core 3 / or about 5 years go? Something like that. Its not really getting updates and its huge/slow compare to built in one. The built in one is much better these days and plays well with other subsystems in aspnet.
    10. anonymars ◴[] No.45901281[source]
    Last I checked they stubbornly insisted on reinventing the wheel and ignoring everything in System.Runtime.Serialization so you had to redecorate everything with their new attributes. For example https://github.com/dotnet/runtime/issues/29975. So we stuck with Newtonsoft for the time being.
    replies(1): >>45905931 #
    11. gf000 ◴[] No.45902502[source]
    Doesn't Text.Json have a much narrower scope and plenty of features supported by Newtonsoft not available?
    replies(1): >>45905380 #
    12. pier25 ◴[] No.45904557[source]
    There's so much stuff they could be working on instead like a first party Postgres driver, better OpenAPI, improving Minimal APIs, etc.
    13. orphea ◴[] No.45905380{3}[source]
    No, not plenty: https://learn.microsoft.com/en-us/dotnet/standard/serializat...
    14. WorldMaker ◴[] No.45905845{3}[source]
    System.Text.Json is out-of-the-box in .NET > 5. The NuGet package is primarily a compatibility layer for people still supporting .NET 4.x for whatever reason.
    15. WorldMaker ◴[] No.45905931{3}[source]
    There is a 3rd Party library for that now: https://github.com/zcsizmadia/ZCS.DataContractResolver

    I haven't tried it because it has generally seemed easiest to use the new attributes. Though a large part of that is the shift from the WCF-era "opt-in" approach of DataContract/DataMember [0] versus the "opt-out" JsonIgnore approach where most of the transition is deleting lines because JsonIgnore is the exception rather than the rule. You could even keep DataContract/DataMember during the transition and just take an additive approach for JsonIgnore.

    [0]: It was a good idea, in theory, but so annoying in practice.

    replies(1): >>45908221 #
    16. anonymars ◴[] No.45908221{4}[source]
    For me it was less not really about the opt-in part (after all, Newtonsoft works the same way) and more about stupid things like setting a name (DataMember), Enums, and in fact opting out (IgnoreDataMember)

    It's especially annoying in libraries because the consumer might not even be using System.Text.Json, but you have to pull in the library anyway to apply its own attributes if you want it to work right. Just an overall awful smell given the existence of first-class framework attributes to do the same thing to avoid just that problem

    Case in point: https://github.com/dotnet/efcore/pull/28084/files