Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.NET JsonConvert vs .NET JavaScriptSerializer [closed]

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

like image 893
Gabbar Avatar asked Jun 29 '12 13:06

Gabbar


People also ask

Is system text JSON better than Newtonsoft?

Text. Json is much faster than the Newtonsoft. Json.

Is JSON net the same as 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.

Is Newtonsoft JSON still supported?

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.

What is the use of JavaScriptSerializer in C #?

Converts a JSON-formatted string to an object of the specified type. Converts the specified JSON string to an object of type T .


2 Answers

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...

  • Is faster
  • Has LINQ to JSON support
  • Can convert JSON to and from XML

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.

like image 57
Haohmaru Avatar answered Sep 20 '22 14:09

Haohmaru


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

like image 22
frenchie Avatar answered Sep 16 '22 14:09

frenchie