4 ms·
I wonder if it'll be possible ever to do Native AOT if you rely on Newtonsoft (which is reflection heavy, last I heard). Yes, yes, I know, use System.Text.Json,
by easton 4y ago
I wonder if it'll be possible ever to do Native AOT if you rely on Newtonsoft (which is reflection heavy, last I heard). Yes, yes, I know, use System.Text.Json, but I already have all this code relying on Newtonsoft-y things :(
- smackeyacky 4y agoIt's worth the work heading to System.Text.Json - even if only to make staying up with .NET easier for yourself. It had a bit of a rough start but it seems far more interoperable on weird edge cases than Newtonsoft now, so all the "Newtonsoft-y" things you're doing might evaporate.
- snarfy 4y agoI've had the opposite experience. System.Text.Json adheres extremely close to the RFC and barely handles any edge cases. Newtonsoft will happily serialize invalid json. Not that you want that but if you have a legacy system it's not worth migrating. James Newton-King is a Microsoft employee btw.
- runevault 4y agoIsn't Text.json also faster at this point because it uses all the new span goodness and the like?
- jcparkyn 4y agoI'm pretty sure it's been faster for as long as it's existed.
- twisteriffic 4y agoTurns out it's easy to be fast if you don't have any features.
- sebazzz 4y agoEven better: it has an optional source generator now! So, at compile time, C# can be generated. This can be at two levels: (1) just generate metadata so runtime reflection is not needed, or (2) also generate code that does the serialisation or deserialization itself. Pretty cool!
- bob1029 4y ago> but I already have all this code relying on Newtonsoft-y things :( Welcome to the dungeon... Our jailer is polymorphic deserialization. We've got many gigabytes of Newtonsoft JSON in prod with that $type property throughout. Any place I can use System.Text.Json I will, but there are a few legacy usages that absolutely won't work. At this point, I'd like to rescind any expectation/desire for Microsoft to support polymorphic deserialization in their JSON library... It was a super powerful trick to get us to the next step, but it eventually turned into a nightmare for codebase maintenance. Until we have this monster refactored, we won't be able to move most of our types into different namespaces or assemblies.