JSON object in client side c#

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

shaitaaan
Posts: 11
Joined: 02 Apr 2009, 04:29
Contact:

JSON object in client side c#

Postby shaitaaan » 03 Apr 2009, 09:28

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?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Apr 2009, 19:18

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
shaitaaan
Posts: 11
Joined: 02 Apr 2009, 04:29
Contact:

Postby shaitaaan » 05 Apr 2009, 23:58

Thanks. We kinda figured that out though. The documentation on onExtensionResponse would be really helpful.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 3 guests