Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605704
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:09:26+00:00 2026-05-18T21:09:26+00:00

.NET provides the JavaScriptSerializer class in the System.Web.Script.Serialization namespace. (provided in System.Web.Extensions.dll) It was

  • 0

.NET provides the JavaScriptSerializer class in the
System.Web.Script.Serialization namespace. (provided in System.Web.Extensions.dll)

It was originally intended to support AJAX web server apps, but the class can be used by any application (client, server, hybrid, anything) that serializes and deserializes .NET classes to JSON. I have a desktop app that captures screenshots and uploads to Facebook, and uses this class to deserialize the response.

would I ever want to look elsewhere for JSON deserialization from within .NET?

If so, why? and where would I Look?


If not, then why does JSON.Net exist? Is it strictly for historical purposes? (ie, because it was created by the community before the JavaScriptSerializer).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:09:26+00:00Added an answer on May 18, 2026 at 9:09 pm

    In my case there are various reasons that prevent me to use JavaScriptSerializer. Here are some of them.

    1) Ugly deserialization when dealing with anonymous types


    While the usage is fairly straight forward for serialization:

    JavaScriptSerializer serializer = new JavaScriptSerializer(); 
    String json = serializer.Serialize(data); 
    

    For deserialization however, there is a minor annoyance in that the deserializer accepts a generic type along with the content:

    serializer.Deserialize<T>(String s) 
    

    this can be a problem if the type T is not known at compile time and needs to be dynamic. The work around is a bit ugly as I learnt because it uses reflection to create a generic method (but it works)

    var result = typeof(JavaScriptSerializer).GetMethod("Deserialize") 
                 .MakeGenericMethod(JsonDataType) 
                 .Invoke(serializer, new object[] { inputContent }); 
    

    Please note: according to Dave Ward comment on this answer there’s a DeserializeObject() that can be used to prevent this.

    2) Cannot handle circular references

    I have seen this using Entity Framework, Linq to SQL, NHibernate, NetTiers and even when using Castle’s proxy.

    According to MS Connect the circular reference exception will be raised when a navigable relation is double-sided (can access both sides of the relation), so the first thing to do is disable one side of the relation. The exception will also be thrown when you use 1:1 relations (or 1:0..1 or any relation causing the creation of an EntityReference type property), in this case the exception will be of type System.Data.Metadata.Edm.AssociationType.

    The solution to this is to make the serializer ignore the properties of type EntityReference, using an empty implementation of a class deriving from JavaScriptConverter and registering it using the RegisterConverters method of the JavaScriptSerializer object.

    3) Useful features that leads to less testable code

    A useful feature of the JavaScriptSerializer is that you can also implement a custom JavaScriptConverter and pass that in to JavaScriptSerializer for fine-grained control over the serialization/deserialization. However, for it to be really useful you need to know the types at compile time and have references to those types. This really limits the usefulness of this feature because by referencing those classes your code becomes tightly coupled so you cannot easily use it in something like an MVC filter.

    For these reasons I have often ended up using Json.NET.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The .net framework provides in the Math class a method for powering double. But
So the .NET framework provides the SecureString class for storing strings in a secure
In .Net the Component class exposes a Disposed event. It also provides a protected
.NET provides EventLog class that be able to write application event information to a
ASP.NET 2.0 provides the ClientScript.RegisterClientScriptBlock() method for registering JavaScript in an ASP.NET Page. The
So .NET 3.0/3.5 provides us with lots of new ways to query, sort, and
I have a complex .NET Remoting server app that provides a couple of services.
I love the ease that the ASP.NET Ajax control Toolkit provides to ASP.NET developers.
.NET provides four very similar versions of String.Format(...) (excluding the one that takes an
.Net provides some wonderful mechanisms for defining a remote service and then automagically creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.