I cannot seem to find the JavaScriptSerializer
object nor the the System.Web.Script.Serialization
namespace within Visual Studio 2010. I need to serialize something to JSON what am I supposed to use?
And yes, I already included the System.Web.Extensions
(in System.Web.Extensions.dll) within the project. Which is why I am shocked?
- I do know
System.Web.Extensions
was marked as obsolete in 3.5
This is how to get JavaScriptSerializer available in your application, targetting
.NET 4.0
(full)This should allow you to create a new
JavaScriptSerializer
object!Are you targeting the .NET 4 framework or the .NET 4 Client Profile?
If you're targeting the latter, you won't find that class. You also may be missing a reference, likely to an extensions dll.
You have to add the reference to the project.
In Assemblies, there is a System.Web.Extensions Add that.
Once that is done put:
That worked for me.
You can use another option which is the Newtonsoft.Json, you can install it from NuGet Package Manager.
Tools >> Nuget Package Manager >> Package Manager Console by issuing command
Install-Package Newtonsoft.Json
or
by using the GUI at Tools >> Nuget Package Manager >> Manage NuGet Packages for Solution...
I'm using Visual Studio 2015 and finally ran across this post.
Yes in order to use
You must right click on references and under Assemblies --> Framework choose
Then add in your reference
From the first search result on google:
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
So, include
System.Web.Extensions.dll
as a reference.