What is better to use when it comes to encoding and decoding of JSON in .NET? I have tried both and upto this point JsonConvert seems to be doing a good job. I have used JavaScriptSerializer in the past successfully but have had some problems in the recent past with it. Is it better to use JSON.NET than the .NET class?
What are the preferred functions for encoding/decoding json using the appropriate library? I use SerializeObject/DeSerializeObject from JSON.NET and Serialize/DeSerialize from .NET.
Thanks
Text. Json is much faster than the Newtonsoft. Json.
Thanks. Json.NET vs Newtonsoft. Json are the same thing. You must be trying to use the same code with different versions of Json.NET.
Json was basically scrapped by Microsoft with the coming of . NET Core 3.0 in favor of its newer offering designed for better performance, System.
Converts a JSON-formatted string to an object of the specified type. Converts the specified JSON string to an object of type T .
I think this is exactly the kind of comparison you are looking for.
It basically says that JSON.Net is better because it among other things...
In my opinion the only positive, (and it is a small positive), I can see for the built-in serializer is that there is no extra external dependency to manage.
Edit: Codeplex is shutting down one day so you can find the comparison here as well, just search for "Feature comparison" on the page.
For a very long time, my app used JavascriptSerializer
and saw no real reason to migrate. Even if performance comparisons claim huge percentage gains, we're talking milliseconds.
But here's one very very good reason to migrate: JavascriptSerializer
isn't available in .Net Core
because it's part of System.Web
So if you're using JavascriptSerializer
, you're stuck and have to migrate to JSON.net
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With