ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ConvertJsonStringToObject

Converts a JSON string to an object

Source

public static T ConvertJsonStringToObject<T>(this string stringToDeserialize)
{
   JavaScriptSerializer serializer = new JavaScriptSerializer();
   return serializer.Deserialize<T>(stringToDeserialize);
}

Example

Person per = jsonString.ConvertJsonStringToObject<Person>();

Author: Otto Beragg

Submitted on: 11 mrt. 2009

Language: C#

Type: System.String

Views: 5965