Using SimpleJson included with UnitySocketIO-WebSocketSharp

I’m currently using UnitySocketIO-WebSocketSharp to send Json datas from server to my Unity clients through SocketIO.
Socket stuff is working fine and I receive message every half seconds in JSON format but I can’t process received datas easily.

I’m new to Json with unity and I would like to use the implementation included with UnitySocketIO-WebSocketSharp but I could only get my Json data as string and I didn’t find any function to retrieve values from a key or a way to get Json object as an array.

I can only do this with received datas:

datas.Json.ToJsonString();

Long strings are a pain to deal with using String.Split() and String.Contains()…
Did someone ever work with this version of SimpleJson and can write an example to parse my datas and retrieve key/value pairs ?

This library which is NOT the same as @Bunny83 (found here) version. The key look up is done through the indexer which you can find on line:153/235. If you use anything that would make the object default out as a string(.ToString() method call for instance), it will serialize the json object as a string(see line:343).

So, say you have constructed/instantiated a SimpleJson object called sj and you want the user name(Key “UserName”).

string user = sj["UserName"]; // Thats it.

There is also a TryGetValue(line:217).

string userName = string.Empty;

sj.TryGetValue("UserName", out userName);

Hi!!
This script its very usefull if you want to manipulate JSON in all the posibbles ways.
http://wiki.unity3d.com/index.php?title=JSONObject