Page 1 of 1

JSON object in client side c#

Posted: 03 Apr 2009, 09:28
by shaitaaan
When I receive an extension message on client side, how do I convert the c# object to JSON object? Or should I use SFSObject itself?

Posted: 05 Apr 2009, 19:18
by ThomasLund
Hi

For a json object you simply cast the object to a JsonData object.

Check the manual here for further info on the actual JsonData object: http://litjson.sourceforge.net/doc/manual.html

I'll put on the todo to make the documentation of OnExtensionResponse a little more explicit with the 3 types of objects.

So in short (written directly here without testing, so a little disclaimer for typos):

Code: Select all

public void OnExtensionResponse(object data, string type)
{
    if (type == SmartFoxClient.XTMSG_TYPE_JSON)
    {
        JsonData responseObject = (JsonData)data;
        // do something with responseObject
    }
}
Best
Thomas

Posted: 05 Apr 2009, 23:58
by shaitaaan
Thanks. We kinda figured that out though. The documentation on onExtensionResponse would be really helpful.