本文整理汇总了C#中SimpleJSON.JSONClass类的典型用法代码示例。如果您正苦于以下问题:C# JSONClass类的具体用法?C# JSONClass怎么用?C# JSONClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONClass类属于SimpleJSON命名空间,在下文中一共展示了JSONClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJSON
//JSON Format:
/*
{
"session": {
"id": "session1234",
"player": "user123",
"game": "game1",
"version": "version 1.0"
},
"play_events" :
[
{ "time": "2015-02-17T22:43:45-5:00", "event": "PowerUp.FireBall", "value": "1.0", "level": "1-1"},
{ "time": "2015-02-17T22:45:45-5:00", "event": "PowerUp.Mushroom", "value": "2.0", "level": "1-1"}
]
}
*/
public static string ToJSON(Gloggr_Report r)
{
JSONNode n = new JSONClass();
n.Add ("session", Gloggr_SessionHeader.ToJSONObject(r.session) );
JSONArray a = new JSONArray();
foreach(Gloggr_PlayEvent e in r.play_events)
{
a.Add(Gloggr_PlayEvent.ToJSONObject(e));
}
n.Add ("play_events", a);
return n.ToString();
// string json = JsonConvert.SerializeObject(e, Formatting.Indented);
// //from Gloggr_SessionHeader.ToJSON
// //json = Gloggr_SessionHeader.FormatJSONKeys(json);
// //from Gloggr_PlayEvent.ToJSON
// //json = Gloggr_PlayEvent.FormatJSONKeys(json);
// return json;
}
示例2: addGameVersion
public void addGameVersion(string id)
{
JSONClass json = new JSONClass ();
json.Add ("gameId", id);
net.POST (url + "/" + id + "/versions" , System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new GameVersionCreatorListener ());
}
示例3: ExportResource
static void ExportResource()
{
int StageNum = 1;
string fileName = "Stage" + StageNum + ".json";
Transform tf = GameObject.Find("BlockRoot").transform;
string seedString = "{\"blocks\":[]}";
JSONNode node = JSON.Parse(seedString);
Transform[] arTF = tf.GetComponentsInChildren<Transform>();
for (int i = 1; i < arTF.Length; i++)
{
Transform subtf = arTF[i];
JSONClass subNode = new JSONClass();
subNode.Add("type", "Normal");
subNode.Add("posX", subtf.position.x + "");
subNode.Add("posY", subtf.position.y + "");
node["blocks"][-1] = subNode;
}
Debug.Log(node.ToString());
writeStringToFile(node.ToString(), fileName);
}
示例4: ConfirmConnectionOut
private void ConfirmConnectionOut(string id){
JSONNode data = new JSONClass();
data["function"] = "Confirm";
data["id"] = id;
udpSend.Send(data);
}
示例5: sendAction
public void sendAction() {
GetComponent<Animator>().Play("Click");
if (buttonType == FLOOR_BUTTON_TYPE.YES || buttonType == FLOOR_BUTTON_TYPE.NO) {
GameObject.Find("Debug Text").GetComponent<Text>().text += "Setting Position \n";
HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/action"), HTTPMethods.Put, actionSentCallback);
JSONClass data = new JSONClass();
data["value"] = ((int)buttonType).ToString();
request.AddHeader("Content-Type", "application/json");
//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
request.RawData = Encoding.UTF8.GetBytes(data.ToString());
request.Send();
} else {
HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/dlswitch"), HTTPMethods.Put, actionSentCallback);
JSONClass data = new JSONClass();
data["value"] = (dlSwitch).ToString();
request.AddHeader("Content-Type", "application/json");
//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
request.RawData = Encoding.UTF8.GetBytes(data.ToString());
request.Send();
}
}
示例6: OnException
public void OnException(Exception e)
{
ServiceAPI sp = AppConstant.GetServce();
JSONClass json = new JSONClass();
json.Add("userId",FB.UserId);
json.Add("userName",AppConstant.GetUserName());
AppConstant.GetStorageService(sp).InsertJSONDocument(AppConstant.DBName, AppConstant.CollectionName,json,this);
}
示例7: GenerateLaunchConfiguration
static JSONNode GenerateLaunchConfiguration(int port)
{
JSONNode N = new JSONClass();
N["version"] = "0.1.0";
N["configurations"][-1] = GenerateUnityConfiguration(port);
return N;
}
示例8: ConnectToServerOut
public void ConnectToServerOut(){
JSONNode data = new JSONClass();
data["function"] = "Connect";
data["id"] = id;
udpSend.Send(data);
}
示例9: GetDictionary
public Dictionary<string, string> GetDictionary(JSONClass N)
{
Dictionary<string, string> d = new Dictionary<string, string>();
foreach (string key in N.GetKeys()) {
d.Add(key, N[key]);
}
return d;
}
示例10: addGame
public void addGame(string title, bool ispublic)
{
JSONClass json = new JSONClass ();
json.Add ("title", new JSONData (title));
json.Add ("public", new JSONData (ispublic));
net.POST (url, System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new GameCreatorListener ());
}
示例11: login
public void login(string user, string pass)
{
JSONClass json = new JSONClass ();
json.Add ("username", new JSONData (this.user));
json.Add ("password", new JSONData (this.pass));
www = net.POST (baseurl + loginurl, System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new LoginListener ());
}
示例12: BuildBytes_NewMatch
public static byte[] BuildBytes_NewMatch()
{
SimpleJSON.JSONClass obj = new SimpleJSON.JSONClass();
obj.Add("sender", AppWarp.localusername);
obj.Add("type", "new_match");
byte[] retVal = System.Text.Encoding.UTF8.GetBytes(obj.ToString());
return retVal;
}
示例13: BuildMessageBytes_Move
public static byte[] BuildMessageBytes_Move( string piece, int gbi )
{
SimpleJSON.JSONClass moveObj = new SimpleJSON.JSONClass();
moveObj.Add("gridBoxIndex", gbi);
moveObj.Add("sender", AppWarp.localusername);
moveObj.Add("piece", piece);
moveObj.Add("type", "move");
return System.Text.Encoding.UTF8.GetBytes(moveObj.ToString());
}
示例14: ToString
public override string ToString()
{
JSONClass json = new JSONClass();
json["uri"] = Uri;
json["complete_uri"] = CompleteUri;
json["ticket_id"] = TicketId;
json["upload_link_secure"] = UploadLinkSecure;
return json;
}
示例15: BuildMessageBytes_OppName
public static byte[] BuildMessageBytes_OppName()
{
SimpleJSON.JSONClass obj = new SimpleJSON.JSONClass();
obj.Add("sender", AppWarp.localusername);
obj.Add("type", "oppName");
byte[] retVal = System.Text.Encoding.UTF8.GetBytes(obj.ToString());
return retVal;
}