PDA

View Full Version : deserialize json with empty value in C# ASP.NET


knowledge
02-28-2010, 05:49 PM
How to deserialize the empty value? If i run this below code i'm getting this error "No parameterless constructor defined for type of 'System.String'." and instead of {} if i use "firstname":"xyz" then it works.

string jstring = "{\"firstname\":{}}";
JavaScriptSerializer serializer = new JavaScriptSerializer();
abc a = serializer.Deserialize<abc>(jstring);

public class abc
{
public string firstname;
}