Vishwajeet Vishwajeet - 11 months ago 59
JSON Question

Convert json into class object in c#

Hi i have the following json response,how i convert it into a c# class object

{ "err_code": "0", "org": "CGK", "des": "SIN", "flight_date": "20120719",

] }


Use JavaScriptSerializer to convert it to a class.

string jsonInput="have your valid json input here"; //
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
Customer objCustomer  = jsonSerializer.Deserialize<Customer >(jsonInput)

Assuming you want to convert it to a Customer classe's instance. Your class should looks similar to the JSON structure (Properties)