当前位置: 首页>>代码示例>>C#>>正文


C# JSONClass.ToString方法代码示例

本文整理汇总了C#中SimpleJSON.JSONClass.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JSONClass.ToString方法的具体用法?C# JSONClass.ToString怎么用?C# JSONClass.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleJSON.JSONClass的用法示例。


在下文中一共展示了JSONClass.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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 ());
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:7,代码来源:AddGameWindow.cs

示例2: 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;
	}
开发者ID:game-design,项目名称:independent-study,代码行数:46,代码来源:Gloggr_Report.cs

示例3: 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();
		}



	}
开发者ID:ubberkid,项目名称:PeerATT,代码行数:35,代码来源:FloorButton.cs

示例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 ());
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:8,代码来源:AddGameWindow.cs

示例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 ());
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:8,代码来源:RageWindow.cs

示例6: 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;
    }
开发者ID:4ONSports,项目名称:Prototype_2,代码行数:9,代码来源:OnlineMessage.cs

示例7: 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;
    }
开发者ID:4ONSports,项目名称:Prototype_2,代码行数:9,代码来源:OnlineMessage.cs

示例8: 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());
 }
开发者ID:4ONSports,项目名称:Prototype_2,代码行数:9,代码来源:OnlineMessage.cs

示例9: DisableRating

        void DisableRating()
        {
            JSONNode data = new JSONClass();
            data = JSON.Parse(EditorPrefs.GetString(keyName));

            data["active"].AsBool = false;
            data["counter"].AsInt = 0;
            EditorPrefs.SetString(keyName, data.ToString());
            this.Close();
        }
开发者ID:mutatis,项目名称:sprawl-brawl,代码行数:10,代码来源:ReviewWindowEditor.cs

示例10: UpdateAI

    void UpdateAI(JSONClass packet)
    {
    
        Debug.Log("Received packet: " + packet.ToString());
        xCoord = packet["x"].AsFloat;
        yCoord = packet["y"].AsFloat;
        angleFacing = packet["facing"].AsFloat;
        Vector2 newPos = new Vector2(xCoord, yCoord);

        transform.rotation = Quaternion.AngleAxis((float)angleFacing, Vector3.forward);
    }
开发者ID:alvinman,项目名称:defendaman,代码行数:11,代码来源:AI.cs

示例11: Startup

        static void Startup()
        {
            EditorApplication.update -= Startup;

            if (!EditorPrefs.HasKey(keyName))
            {
                JSONNode data = new JSONClass();
                data["active"].AsBool = true;
                EditorPrefs.SetString(keyName, data.ToString());
            }

            Count();
        }
开发者ID:mutatis,项目名称:sprawl-brawl,代码行数:13,代码来源:ReviewWindowEditor.cs

示例12: connectToDb

        public string connectToDb()
        {
            //make sure all the paramter has something
            if (!System.String.IsNullOrEmpty(function) && !System.String.IsNullOrEmpty(url) && parameterList.Count > 0 && valueList.Count > 0)
            {
                WebClient webClient = new WebClient();
                NameValueCollection formData = new NameValueCollection();
                var sendJSON = new JSONClass();

                //get the values to be sent to backend
                for (int i=0; i < parameterList.Count;i++)
                {
                    string key = (string)parameterList[i];
                    sendJSON["info"][key] = (string)valueList[i];
                }

                //send to backend
                sendJSON["function"] = this.function;
                formData["send"] = sendJSON.ToString();
                byte[] responseBytes = webClient.UploadValues(this.url, "POST", formData);
                string responsefromserver = Encoding.UTF8.GetString(responseBytes);
                Debug.Log(responsefromserver);

                //parse the return values
                var returnValue = JSONNode.Parse(responsefromserver);
                int error = Convert.ToInt32(returnValue["error"]);

                if (error != -1)
                {
                    //if got error, parse it and return the appropriate error message
                    string errorString = this.parseError(error);
                    return errorString;

                } else {

                    //if no error, return "SUCCESS NO RETURN" if only "TRUE" is returned by backend
                    this.jsonReturn = returnValue["result"][0].ToString();
                    if (String.Compare(this.jsonReturn, "\"TRUE\"") == 0)
                    {
                        return "SUCCESS NO RETURN";
                    } else {
                        return "SUCCESS";
                    }
                }

                //return "";

            }

            return "you did not insert a function/parameter/value";
        }
开发者ID:jiangkuo888,项目名称:ORP_beta,代码行数:51,代码来源:dbConnect.cs

示例13: SaveCompletedQuest

    public void SaveCompletedQuest(Quest questToSave)
    {
        if (PlayerPrefs.HasKey ("CompletedQuests") == true) {
            JSONNode completedQuests = JSONClass.Parse(PlayerPrefs.GetString("CompletedQuests"));
            for(int i = 0; i < completedQuests["CompletedQuest"].Count; i++){
                if(completedQuests["CompletedQuests"][i] == questToSave.GetID().ToString()){
                    completedQuests["CompletedQuests"][-1] = questToSave.GetID().ToString();
                    PlayerPrefs.SetString("CompletedQuests", completedQuests.ToString());
                    return;
                }
            }
        }

        JSONClass completedQuestJSONNode = new JSONClass ();
        completedQuestJSONNode ["CompletedQuests"] [0] = questToSave.GetID ().ToString();
        PlayerPrefs.SetString("CompletedQuests", completedQuestJSONNode.ToString());
        return;
    }
开发者ID:chicostategamestudios,项目名称:qk-pop,代码行数:18,代码来源:QuestSaveManager.cs

示例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;
    }
开发者ID:4ONSports,项目名称:Prototype_2,代码行数:18,代码来源:OnlineMessage.cs

示例15: Count

        static void Count()
        {
            JSONNode data = new JSONClass();
            data = JSON.Parse(EditorPrefs.GetString(keyName));

            if(data["active"].AsBool == false)
                return;

            double time = GenerateUnixTime();
            double diff = time - data["lastCheck"].AsDouble;
            if(diff < 20) return;

            data["lastCheck"].AsDouble = time;
            data["counter"].AsInt = data["counter"].AsInt + 1;
            EditorPrefs.SetString(keyName, data.ToString());

            if(data["counter"].AsInt > 10)
                Init();
        }
开发者ID:mutatis,项目名称:sprawl-brawl,代码行数:19,代码来源:ReviewWindowEditor.cs


注:本文中的SimpleJSON.JSONClass.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。