Reputation: 36654
I wrote an application project in c#. Is there a way to serialize a collection to Json string format? If I use C#4? C#3?
Another q: within Visual Studio 2010 ultimate I remember I could search and download dll from the web: Web Downlaoder or so. I cnnot find it again. Does any one know it?
TIA
Upvotes: 0
Views: 1165
Reputation: 1038820
JavaScriptSerializer is one way to go:
MyType[] collection = ...
string json = new JavaScriptSerializer().Serialize(collection);
Upvotes: 3
Reputation: 37366
Install Nuget http://nuget.org/ using visual studio extension manager, look for json.net in nuget (right click on your project and select Manage nuget packages), add it to your project, you can serialize using this library without adding dependency on system.web
Upvotes: 1
Reputation: 15569
One way is to Use the DataContractJsonSerializer.
http://msdn.microsoft.com/en-us/library/bb410770.aspx
Upvotes: 1
Reputation: 3052
Take a look at Json.net for the Json serialising/deserialising
For downloading the .dlls you probably saw nuget. Once it's installed you can right click on the references folder in the solution explorer and select manage packages.
Upvotes: 1