After Asp.Net web development process, many times encounter object serialization and de-serialization operations, Newtonsoft.Json component is designed to serialize and deserialize a functional component operations, the introduction of this DLL component , the method can be used to deserialize JsonConvert.DeserializeObject string objects, there are two methods JsonConvert.DeserializeObject overloads signatures are available for deserialization string in C #.
JsonConvert.DeserializeObject overloaded methods commonly used method signature as follows:
(1) object DeserializeObject (string value): deserialize string Object type of object
(2) T DeserializeObject <T> (string value): deserialize the string specified type of object T, T is the generic type C # syntax represents the concrete setting time.
To use Newtonsoft.Json component string to deserialize objects as follows:
(1) first introduced Newtonsoft.Json.Dll project components in the project
(2) introducing the assembly in the namespace: using Newtonsoft.Json;
(3) where the specific method JsonConvert.DeserializeObject call expects a string deserialization. Specific examples are as follows: there is a reception of the incoming serialized string jsonStr, it is necessary to deserialize objects TestModel, the following statement may be used for implementation.
Test Model solid model JsonConvert.DeserializeObject = <Test Model> (jsonStr);
The above statement is generic wording, if you just want to deserialize object type can be used directly following statement:
object testModel = JsonConvert.DeserializeObject(jsonStr);
Note: The text reproduced from personal bloggers station IT technology small fun house , the original link for the C # using Newtonsoft.Json component to deserialize string objects _IT technology small fun house .