LitJSON's JsonMapper.ToJson error: Max allowed object depth reached while trying to export from type
        Posted  
        
            by dev.e.loper
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dev.e.loper
        
        
        
        Published on 2010-03-30T14:21:38Z
        Indexed on 
            2010/03/30
            14:23 UTC
        
        
        Read the original article
        Hit count: 3881
        
I have an object that I would like to convert to json inside one of the object's methods. I'm using LitJson library. Like so:
    protected override void Render(HtmlTextWriter writer)
{
    ...
    writer.AddAttribute(HtmlTextWriterAttribute.Value, JsonMapper.ToJson(this));
    ....
}
However JsonMapper.ToJson(this) produces a server error
"Max allowed object depth reached while trying to export from type System.Drawing.Color".
My guess is that because its trying to convert an object inside itself its going into some kind of infinite loop. Just curious what is actually happening.
© Stack Overflow or respective owner