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


C# JSONObject.AddField方法代码示例

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


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

示例1: BuildManifest

        public static void BuildManifest()
        {
            JSONObject json = new JSONObject(JSONObject.Type.ARRAY);
            string[] levels = Directory.GetFiles(Application.dataPath + "/Levels_Exported/", "*.json");

            for (int i = 0; i < levels.Length; i++) {
                JSONObject data = new JSONObject(JSONObject.Type.OBJECT);
                string fileContents = File.ReadAllText(levels[i]);
                string hash = LevelManagementUtils.Hash(fileContents);
                data.AddField("Hash", hash);
                string url = levels[i].Replace(Application.dataPath, "http://podshot.github.io/TwoTogether" /*"http://127.0.0.1:8000/"*/);
                url = url.Replace("_Exported", "");
                data.AddField("URL", url);
                data.AddField("Name", levels[i].Replace(Application.dataPath + "/Levels_Exported/", ""));

                JSONObject thumb = new JSONObject(JSONObject.Type.OBJECT);
                thumb.AddField("URL", "http://podshot.github.io/TwoTogether/Thumbnails/" + levels[i].Replace(Application.dataPath + "/Levels_Exported/", "").Replace(".json", ".png"));
                thumb.AddField("Name", levels[i].Replace(Application.dataPath + "/Levels_Exported/", "").Replace(".json", ".png"));

                data.AddField("Thumbnail", thumb);
                json.Add(data);
            }

            TextWriter writer = new StreamWriter(Application.dataPath + "/Levels_Exported/levels_.manifest");
            writer.WriteLine(json.ToString(true));
            writer.Close();
            Debug.Log("Wrote manifest file");
        }
开发者ID:Podshot,项目名称:TwoTogether,代码行数:28,代码来源:BuildLevelManifest.cs

示例2: ListStorePage

        public KnetikApiResponse ListStorePage(
            int page = 1,
            int limit = 10,
            List<string> terms = null,
            List<string> related = null,
            bool useCatalog = true,
            Action<KnetikApiResponse> cb = null
        )
        {
            JSONObject j = new JSONObject (JSONObject.Type.OBJECT);
            j.AddField ("page", page);
            j.AddField ("limit", limit);
            if (terms != null) {
                j.AddField ("terms", JSONObject.Create(terms));
            }
            if (related != null) {
                j.AddField ("related", JSONObject.Create(related));
            }
            j.AddField("useCatalog", useCatalog);

            String body = j.Print ();

            KnetikRequest req = CreateRequest(ListStorePageEndpoint, body);

            KnetikApiResponse response = new KnetikApiResponse(this, req, cb);
            return  response;
        }
开发者ID:knetikmedia,项目名称:UnitySDK,代码行数:27,代码来源:Store.cs

示例3: ToJSONObj

		public static JSONObject ToJSONObj(string userPayload, string rewardId = "")
		{
			JSONObject obj = new JSONObject(JSONObject.Type.OBJECT);
			obj.AddField(USER_PAYLOAD, userPayload);
			obj.AddField(REWARD_ID, rewardId);
			return obj;
		}
开发者ID:drapermovies,项目名称:MansionGamingGitHub,代码行数:7,代码来源:ProfilePayload.cs

示例4: ParseToJsonResult

    //Creates a JSON from a resultModel and parses it to the POSTFacade
    public void ParseToJsonResult(ResultModel resultModel, string command)
    {
        JSONObject json = new JSONObject (JSONObject.Type.OBJECT);

            json.AddField("UserID", resultModel.UserID);
            json.AddField("UserType", resultModel.UserType);

            JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
            json.AddField("Answers",arr);
            foreach(QuizOptionModel qm in resultModel.Options){
            JSONObject ans = new JSONObject(JSONObject.Type.OBJECT);
                ans.AddField("ID",qm.Id);
                ans.AddField("Title",qm.Title);
                ans.AddField("Selected",qm.Selected);

            arr.Add(ans);
            }
        switch(command){
        case "SaveToServer":
        POSTFacade facade = gameObject.GetComponent<POSTFacade> ();
            facade.SaveQuizAnswers (json,resultModel.UserID.ToString());
            break;
        case "SaveLocal":
            PlayerPrefs.SetString("TestToSave_"+resultModel.UserID, json.Print());
            break;
        }
    }
开发者ID:oervald,项目名称:MentorDanmark,代码行数:28,代码来源:POSTResultCalculator.cs

示例5: OnCollisionEnter2D

    void OnCollisionEnter2D( Collision2D col )
    {
        if( col.gameObject.name == "RocketLeft" ){
            float py = HitFactor(transform.position, col.transform.position, col.collider.bounds.size.y);

            JSONObject data = new JSONObject();
            data.AddField("float", py.ToString());
            data.AddField("rocket", col.gameObject.name);
            NetworkManager.Instance.Socket.Emit("SHOOT", data );
            GetComponent<Rigidbody2D>().velocity = Vector2.zero;
            //Vector2 direction = new  Vector2(1,py).normalized;
            //GetComponent<Rigidbody2D>().velocity = direction*ballSpeed;
        }

        if( col.gameObject.name == "RocketRight" ){
            float py = HitFactor(transform.position, col.transform.position, col.collider.bounds.size.y);
            JSONObject data = new JSONObject();
            data.AddField("float", py.ToString());
            data.AddField("rocket", col.gameObject.name);
            NetworkManager.Instance.Socket.Emit("SHOOT", data );
            GetComponent<Rigidbody2D>().velocity = Vector2.zero;
            //Vector2 direction = new  Vector2(-1,py).normalized;
            //GetComponent<Rigidbody2D>().velocity = direction*ballSpeed;
        }
    }
开发者ID:shunlll999,项目名称:pong-unity,代码行数:25,代码来源:Ball.cs

示例6: toJSONObject

 public JSONObject toJSONObject()
 {
     JSONObject obj = new JSONObject();
     obj.AddField(JSONConsts.SOOM_ENTITY_ID, this.ID);
     obj.AddField(PJSONConsts.UP_PROVIDER, this.Provider.ToString());
     return obj;
 }
开发者ID:fordream,项目名称:unity3d-profile,代码行数:7,代码来源:Leaderboard.cs

示例7: FromVector3

	/*
	 * Vector3
	 */
	public static JSONObject FromVector3(Vector3 v) {
		JSONObject vdata = new JSONObject(JSONObject.Type.OBJECT);
		if(v.x != 0)	vdata.AddField("x", v.x);
		if(v.y != 0)	vdata.AddField("y", v.y);
		if(v.z != 0)	vdata.AddField("z", v.z);
		return vdata;
	}
开发者ID:trananh1992,项目名称:3DActionGame,代码行数:10,代码来源:VectorTemplates.cs

示例8: Serialize

        public static void Serialize(this Template template)
        {
            // Template
            var tplJs = new JSONObject(JSONObject.Type.OBJECT);

            // Operators
            var opsJs = new JSONObject(JSONObject.Type.ARRAY);
            tplJs.AddField("Operators", opsJs);

            foreach (KeyValuePair<string, Operator> kvp in template.Operators) {
                opsJs.Add(kvp.Value.Serialize());
            }

            // Connections
            var connsJs = new JSONObject(JSONObject.Type.ARRAY);
            tplJs.AddField("Connections", connsJs);

            foreach (IOConnection conn in template.Connections) {
                connsJs.Add(conn.Serialize());
            }

            template.JSON = tplJs.Print(true);

            #if UNITY_EDITOR
            EditorUtility.SetDirty(template);
            #endif
        }
开发者ID:BrettRToomey,项目名称:forge,代码行数:27,代码来源:TemplateSerializer.cs

示例9: encode

 public JSONObject encode()
 {
     JSONObject obj = new JSONObject();
     obj.AddField("name", name);
     obj.AddField("points", points);
     return obj;
 }
开发者ID:BU-HuangJ,项目名称:project3,代码行数:7,代码来源:Achievement.cs

示例10: Update

	void Update(){

		if (_block)return;

		int dec = 128;
		float[] waveData = new float[dec];
		int micPosition = Microphone.GetPosition(null)-(dec+1); // null means the first microphone
		audio.clip.GetData(waveData, micPosition);
		
		// Getting a peak on the last 128 samples
		float levelMax = 0;
		for (int i = 0; i < dec; i++) {
			float wavePeak = waveData[i] * waveData[i];
			if (levelMax < wavePeak) {
				levelMax = wavePeak;
			}
		}
		// levelMax equals to the highest normalized value power 2, a small number because < 1
		// use it like:
		float volume = Mathf.Sqrt(levelMax);
		if (volume > threashHold) 
		{
			_block = true;
			Invoke("unblock",cooldown);
			Debug.Log ("volume:" + volume);
			JSONObject commandJsonObject = new JSONObject();
			commandJsonObject.AddField("command","microphone");
			commandJsonObject.AddField("value",volume);
			communicationManager.SendJson (commandJsonObject);
		}
	}
开发者ID:huw12313212,项目名称:GlassGames,代码行数:31,代码来源:MicListener.cs

示例11: Json

 public Json(string name1,string arg1,string name2,float arg2,string name3,float arg3)
 {
     json = new JSONObject ();
     json.AddField (name1, arg1);
     json.AddField (name2, arg2);
     json.AddField (name3, arg3);
 }
开发者ID:alciakng,项目名称:WormsClient,代码行数:7,代码来源:Json.cs

示例12: Register

        public KnetikApiResponse Register(
			string username,
			string password,
			string email,
			string fullname,
			Action<KnetikApiResponse> cb = null
		)
        {
            // Login as a guest
            KnetikApiResponse loginResponse = GuestLogin ();

            if (loginResponse.Status != KnetikApiResponse.StatusType.Success) {
                Debug.LogError("Guest login failed");
                return loginResponse;
            }
            Debug.Log ("Guest login successful");

            // Then register the new user
            JSONObject j = new JSONObject (JSONObject.Type.OBJECT);
            j.AddField ("username", username);
            j.AddField ("password", password);
            j.AddField ("email", email);
            j.AddField ("fullname", fullname);

            String body = j.Print ();

            KnetikRequest req = CreateRequest(RegisterEndpoint, body);

            KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb);
            return  registerResponse;
        }
开发者ID:knetikmedia,项目名称:UnitySDK,代码行数:31,代码来源:Registration.cs

示例13: stopped

	void stopped(){
		JSONObject commandJsonObject = new JSONObject();
		commandJsonObject.AddField("command","move");
		commandJsonObject.AddField("x",0);
		commandJsonObject.AddField("y",0);
		
		communicationManager.SendJson (commandJsonObject);
	}
开发者ID:huw12313212,项目名称:GlassGames,代码行数:8,代码来源:JoystickManager.cs

示例14: rotated

	void rotated(Vector3 vec3){
		JSONObject commandJsonObject = new JSONObject();
		commandJsonObject.AddField("command","rotate");
		commandJsonObject.AddField("x",vec3.x);
		commandJsonObject.AddField("y",-(vec3.y));
		
		communicationManager.SendJson (commandJsonObject);
	}
开发者ID:huw12313212,项目名称:GlassGames,代码行数:8,代码来源:JoystickManager.cs

示例15: toJSONObject

		public JSONObject toJSONObject() {
			JSONObject obj = new JSONObject();
			obj.AddField(PJSONConsts.UP_IDENTIFIER, this.ID);
			obj.AddField(PJSONConsts.UP_PROVIDER, this.Provider.ToString());
			obj.AddField(PJSONConsts.UP_NAME, this.Name);
			obj.AddField(PJSONConsts.UP_ICON_URL, this.IconURL);
			return obj;
		}
开发者ID:Faisalimrann,项目名称:Shop,代码行数:8,代码来源:Leaderboard.cs


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