Convert Struct to JSON
c#, json, struct
Solution
JavaScriptSerializer Class
var serializer = new JavaScriptSerializer();
YourStruct myStruct = new YourStruct(x,y,z);
var json = serializer.Serialize(myStruct);
JSON.NET
The other alternative JSON.net, does not depend on System.Web.* assemblies:
YourStruct myStruct = new YourStruct(x,y,z);
var json = JsonConvert.SerializeObject(myStruct);
Problem
I have a struct, I want to convert it to JSON and save it as local file. I couldn't find any source that explain how to convert a C# struct into a JSON. I am using a console application for that, not a webservice/web, etc.