本文整理汇总了C#中SimpleJSON.JSONClass.Add方法的典型用法代码示例。如果您正苦于以下问题:C# JSONClass.Add方法的具体用法?C# JSONClass.Add怎么用?C# JSONClass.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleJSON.JSONClass
的用法示例。
在下文中一共展示了JSONClass.Add方法的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: 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);
}
示例3: 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);
}
示例4: 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 ());
}
示例5: 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 ());
}
示例6: 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;
}
示例7: 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());
}
示例8: 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;
}
示例9: ToJSONObject
public static JSONNode ToJSONObject(Gloggr_SessionHeader e)
{
JSONNode n = new JSONClass();
n.Add ("id", new JSONData( e.gSessionID));
n.Add ("player", new JSONData(e.gPlayer));
n.Add ("game", new JSONData(e.gGameName));
n.Add ("version", new JSONData(e.gVersion));
return n;
}
示例10: ToJSONObject
public static JSONNode ToJSONObject(Gloggr_PlayEvent e)
{
JSONNode n = new JSONClass();
n.Add ("time", new JSONData( e.gTime));
n.Add("event", new JSONData(e.gEvent));
n.Add("value", new JSONData(e.gValue));
n.Add("position", new JSONData(e.gPosition));
n.Add("level", new JSONData(e.gLevel));
return n;
}
示例11: 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 ());
}
示例12: OnGUI
void OnGUI()
{
if (Time.time % 2 < 1) {
success = callBack.getResult();
}
// For Setting Up ResponseBox.
GUI.TextArea(new Rect(10,5,1300,175), success);
//=========================================================================
if (GUI.Button(new Rect(50, 200, 200, 30), "Run Java Code"))
{
App42Log.SetDebug(true);
customCodeService = sp.BuildCustomCodeService(); // Initializing CustomCodeService.
JSONClass jsonBody = new JSONClass();
jsonBody.Add("name" ,"John");
jsonBody.Add("age",30);
customCodeService.RunJavaCode(cons.customServiceName,jsonBody,new CustomCodeResponse());
}
}
示例13: DoSync
void DoSync()
{
JSONClass cl = new JSONClass();
JSONData dt_p1_mana = new JSONData(p1_mana);
JSONData dt_p2_mana = new JSONData(p2_mana);
JSONData dt_pop_all = new JSONData(pop_all);
JSONData dt_pop_p1 = new JSONData(pop_p1);
JSONData dt_pop_p2 = new JSONData(pop_p2);
cl.Add("p1_mana",dt_p1_mana);
cl.Add("p2_mana",dt_p2_mana);
cl.Add("pop_all",dt_pop_all);
cl.Add("pop_p1",dt_pop_p1);
cl.Add("pop_p2",dt_pop_p2);
string data = cl.SaveToBase64();
pview.RPC("GameResources_DoSyncGet",PhotonTargets.Others,data);
//nview.RPC("GameResources_DoSyncGet", RPCMode.Others, data);
//Debug.Log ("sending data to client");
}
示例14: BuildBytes_OnlineEvent
public static byte[] BuildBytes_OnlineEvent( OnlineGameEvent _ge )
{
SimpleJSON.JSONClass obj = new SimpleJSON.JSONClass();
obj.Add("sender", AppWarp.localusername);
obj.Add("type", "online_event");
obj.Add("gE", (int)_ge.gameEvent);
if( _ge.gameEventProperty != null ) {
obj.Add("hasEP", true);
obj.Add("gEP", _ge.gameEventProperty);
}
else {
obj.Add("hasEP", false);
obj.Add("gEP", "");
}
byte[] retVal = System.Text.Encoding.UTF8.GetBytes(obj.ToString());
return retVal;
}
示例15: writePlayerPrefs
public IEnumerator writePlayerPrefs()
{
JSONClass root = new JSONClass();
JSONClass users = new JSONClass();
JSONClass wep = new JSONClass();
JSONClass wep2 = new JSONClass();
JSONArray weapons = new JSONArray();
users.Add("user_id", ""+ PlayerPrefs.GetInt("user_id"));
users.Add("total_kills", ""+ PlayerPrefs.GetInt("total_kills"));
users.Add("total_points", ""+ PlayerPrefs.GetInt("total_points"));
users.Add("red", "" + PlayerPrefs.GetFloat("BaseRed"));
users.Add("green", "" + PlayerPrefs.GetFloat("BaseGreen"));
users.Add("blue", "" + PlayerPrefs.GetFloat("BaseBlue"));
users.Add("highest_round_reached", "" + PlayerPrefs.GetInt("highestRound"));
users.Add("points_available", "" + PlayerPrefs.GetInt("points_available"));
root.Add("user_params", users);
Debug.Log(root.ToString());
byte[] data = Encoding.UTF8.GetBytes(root.ToString());
WWW www = new WWW(ROOT_URL + POST_USER_URL, data);
yield return WaitForRequest(www);
}