I'm trying to serialize a local object to json but msdn documentation always seems to confuse me. I believe I am suppose to use the DataContractJsonSerializer but not completely sure, as I have seen mixed responses. I've also had someone recommend Newtonsoft.
Does anyone have any experience with this that can point me in the right direction?
Serialization is the process of converting . NET objects such as strings into a JSON format and deserialization is the process of converting JSON data into . NET objects.
The purpose of serializing it into JSON is so that the message will be a format that can be understood and from there, deserialize it into an object type that makes sense for the consumer.
The json module exposes two methods for serializing Python objects into JSON format. dump() will write Python data to a file-like object. We use this when we want to serialize our Python data to an external JSON file. dumps() will write Python data to a string in JSON format.
You could use the JavaScriptSerializer.
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
var thing = new Thing(); var json = new JavaScriptSerializer().Serialize(thing);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With