I'm using JavascriptSerializer to convert the list into string, but its not working and its throwing an error as Recursion Limit Exceeded
. I have searched a lot but i didn't found any solutions to overcome this issue.
My conversion is like below
List<CustomType> _customValues= serializer.ConvertToType<List<CustomType>>(dictionary["CustomValues"]);
string CustomString = new JavaScriptSerializer().Serialize(_customValues);
EDIT
My custom type is below
public class CustomType
{
private string _name;
public string Name
{
get
{ return _name; }
set
{
if (this._name != value)
{
this._name= value;
}
}
}
private double _mark;
public double Mark
{
get
{ return _mark; }
set
{
if (this._mark!= value)
{
this._mark= value;
}
}
}
private int _id;
public int Id
{
get
{ return _id; }
set
{
if (this._id!= value)
{
this._id= value;
}
}
}
}
How can i convert that list into string?. How can i overcome this issue?.
Thanks,
Karthik
Use a JSON Serializer that ignores circular references.
System.Web.Script.Serialization.JavaScriptSerializer
can't ignore circular references and will easily get stuck in recursion and reach recursion limit.