The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

json Serialization issue

Last post 07-20-2007, 3:53 PM by kwilder. 3 replies.
Sort Posts: Previous Next
  •  07-20-2007, 11:03 AM 3982

    json Serialization issue

    I'm not sure if I'm in the right place for this, but I was wondering if anyone has tried to serialize ES as JSON using ASP.NET AJAX?

    With ASP.NET AJAX, I'm trying to send a JSON object from browser (Javascript) to a Webservice (ASMX).  The JSON object is going into the web service method ok, but it seems like the jsonSerializer is choking on all the "upto[Methodname]" childs in the entity class. 

    I get the error: RecursionLimit exceeded.

    If anyone has tried this with ES and succeeded, I would love to know what to do to get past this error.

    I've also tried using Newtonsofts JSON.Net object and it also doesn't like all the children.

    I've tried, fairly successfully, to use Jayrock's JSON implementation, and it does work for the most part.  But it only seems to work when I send individual arguments back to the Jayrock handler.  When I try and send a JSON object, I get an error.

    Essentially, I need to send a single JSON object back to the .Net handler because I need to send any number of arguments back to the class, and I won't know ahead of time how many arguments I'll need, so it is done dynamically.  I hope I not too confusing, but the JSON object will contain the arguments and I will loop through them and send them to my entity to retrieve the appropriate data.

     

    Thanks,


    King Wilder
    http://www.kingwilder.com
  •  07-20-2007, 12:52 PM 3987 in reply to 3982

    Re: json Serialization issue

    I have no experience with Json, but a quick Google on "json serializer ignore", turned up this:

    http://www.newtonsoft.com/blog/archive/2007/01/20/Json.NET-1.2-released.aspx

    "New feature - Added JsonIgnoreAttribute. This is the equivalent to XmlIgnoreAttribute for XML serialization."

    Does that help? EntitySpaces has many properties with the [XmlIgnore] attribute on them to prevent endless loops.


    David Neal Parsons
    www.entityspaces.net
  •  07-20-2007, 12:59 PM 3988 in reply to 3987

    Re: json Serialization issue

    You might try generating without hierarchical.

    Regards,

    Scott Schecter
    EntitySpaces | My Site
  •  07-20-2007, 3:53 PM 3994 in reply to 3988

    Re: json Serialization issue

    Scott,

    It worked when I regenerated without the hierarchical.  I don't think I'll need it, but if I do I'll think of something.

    David,

    I thought of the Ignore attributes, but I don't really know how to implement them on the ES objects.  I'll look into it a bit more when I have a moment.  Right now I need to finish the job and it's all working nicely now.

    Thanks guys.


    King Wilder
    http://www.kingwilder.com
View as RSS news feed in XML