• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JSONObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseData

 void parseData(string data)
 {
     JSONObject json = new JSONObject (data);
     string action = json.GetField ("action").str;
     print(action + "parse data" + data);
     JSONObject pos = json.GetField("position");
     Single pX = Convert.ToSingle (pos.GetField ("X").str);
     Single pY = Convert.ToSingle (pos.GetField ("Y").str);
     Single pZ = Convert.ToSingle (pos.GetField ("Z").str);
     Vector3 position = new Vector3 (pX, pY, pZ);
     print ("new vector = x-" + pos.GetField ("X").str + " y-" + pos.GetField ("Y").str);
     JSONObject rot = json.GetField("rotation");
     Single rX = Convert.ToSingle (rot.GetField ("X").str);
     Single rY = Convert.ToSingle (rot.GetField ("Y").str);
     Single rZ = Convert.ToSingle (rot.GetField ("Z").str);
     Single rW = Convert.ToSingle (rot.GetField ("W").str);
     Quaternion rotation = new Quaternion (rX, rY, rZ, rW);
     switch (action) {
         case "start":
             this.id = json.GetField ("id").str;
             createPlayer ();
             break;
         case "newPlayer":
             createNewClient (json.GetField ("id").str, position, rotation);
             break;
         case "move":
             moveClient (json.GetField ("id").str, position, rotation);
             break;
     }
 }
开发者ID:Bibazoo,项目名称:UnityClientServer,代码行数:30,代码来源:EventListener.cs


示例2: Update

	// Update is called once per frame
	void Update () {

		lastQ = Input.gyro.attitude;
		lastAcc = Input.acceleration;

		if (Transfering) {

			counter += Time.deltaTime;

						if (counter > updateRate) {
								counter = 0;

								JSONObject json = new JSONObject ();
								json.AddField ("command", "gyro");
								json.AddField ("x", lastQ.x);
								json.AddField ("y", lastQ.y);
								json.AddField ("z", lastQ.z);
								json.AddField ("w", lastQ.w);
								json.AddField ("accX", lastAcc.x);
								json.AddField ("accY", lastAcc.y);
								json.AddField ("accZ", lastAcc.z);
								communicationManager.SendJson (json);


						}

				}

	}
开发者ID:huw12313212,项目名称:GlassGames,代码行数:30,代码来源:GyroManager.cs


示例3: AddScore

 /// <summary>
 /// Adds Score to database
 /// </summary>
 /// <param name="name"></param>
 /// <param name="id"></param>
 /// <param name="score"></param>
 /// <returns></returns>
 private IEnumerator AddScore(string name, string id, string score)
 {
     WWWForm f = new WWWForm();
     f.AddField("ScoreID", id);
     f.AddField("Name", name);
     f.AddField("Point", score);
     WWW w = new WWW("demo/theappguruz/score/add", f);
     yield return w;
     if (w.error == null)
     {
         JSONObject jsonObject = new JSONObject(w.text);
         string data = jsonObject.GetField("Status").str;
         if (data != null && data.Equals("Success"))
         {
             Debug.Log("Successfull");
         }
         else
         {
             Debug.Log("Fatel Error");
         }
     }
     else
     {
         Debug.Log("No Internet Or Other Network Issue" + w.error);
     }
 }
开发者ID:power7714,项目名称:centralized-leader-board-unity-used-personal-web-api,代码行数:33,代码来源:Test.cs


示例4: ToVector4

	public static Vector4 ToVector4(JSONObject obj) {
		float x = obj["x"] ? obj["x"].f : 0;
		float y = obj["y"] ? obj["y"].f : 0;
		float z = obj["z"] ? obj["z"].f : 0;
		float w = obj["w"] ? obj["w"].f : 0;
		return new Vector4(x, y, z, w);
	}
开发者ID:trananh1992,项目名称:3DActionGame,代码行数:7,代码来源:VectorTemplates.cs


示例5: 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


示例6: ProcessMyGameStateResponse

        private static void ProcessMyGameStateResponse(JSONObject jsonData)
        {
            if (jsonData.GetField ("gameStates")) {
                JSONObject gameStateData = jsonData.GetField ("gameStates");

                for (int i = 0; i < gameStateData.list.Count; i++) {
                    JSONObject gameState = gameStateData.list [i];

                    string access = null;
                    if (gameState.HasField ("access")) {
                        access = gameState.GetField ("access").str;
                    }

                    string data = null;
                    if (gameState.HasField ("data")) {
                        data = gameState.GetField ("data").str;
                    }

                    if (access != null && data != null) {
                        if (access.Equals ("private")) {
                            PrivateGameStateData = data;
                            SpilUnityImplementationBase.fireGameStateUpdated ("private");
                        } else if (access.Equals ("public")) {
                            PublicGameStateData = data;
                            SpilUnityImplementationBase.fireGameStateUpdated ("public");
                        }
                    }
                }
            }
        }
开发者ID:spilgames,项目名称:spil_event_unity_plugin,代码行数:30,代码来源:GameStateResponse.cs


示例7: accessData

    void accessData(JSONObject obj)
    {
        switch(obj.type){
            case JSONObject.Type.OBJECT:
                for(int i = 0; i < obj.list.Count; i++){
                    string key = (string)obj.keys[i];
                    JSONObject j = (JSONObject)obj.list[i];
                    Debug.Log(key);
                    accessData(j);
                }
                break;
            case JSONObject.Type.ARRAY:
                foreach(JSONObject j in obj.list){
                    accessData(j);
                }
                break;
            case JSONObject.Type.STRING:
                Debug.Log(obj.str);
                break;
            case JSONObject.Type.NUMBER:
                Debug.Log(obj.n);
                break;
            case JSONObject.Type.BOOL:
                Debug.Log(obj.b);
                break;
            case JSONObject.Type.NULL:
                Debug.Log("NULL");
                break;

        }
    }
开发者ID:Ruixel,项目名称:CYplayer,代码行数:31,代码来源:worldGen.cs


示例8: ToVector3

 public static Vector3 ToVector3(JSONObject obj)
 {
     float x = obj["x"] ? obj["x"].f : 0;
     float y = obj["y"] ? obj["y"].f : 0;
     float z = obj["z"] ? obj["z"].f : 0;
     return new Vector3(x, y, z);
 }
开发者ID:kibotu,项目名称:unity-socket.io,代码行数:7,代码来源:VectorTemplates.cs


示例9: Update

    public void Update()
    {
        if (dataLoaded || currencyWWW == null || !currencyWWW.isDone) return;

        // let's look at the results
        JSONObject j = new JSONObject(currencyWWW.text);

        j.GetField("list", delegate (JSONObject list) {

            list.GetField("resources", delegate (JSONObject resources) {
                foreach (JSONObject entry in resources.list)
                {
                    entry.GetField("resource", delegate (JSONObject resource) {
                        resource.GetField("fields", delegate (JSONObject fields) {
                            string name;
                            string price;
                            string volume;

                            fields.GetField(out price, "price", "-1");
                            fields.GetField(out name, "name", "NONAME");
                            fields.GetField(out volume, "volume", "NOVOLUME");

                            CurrencyData data = new CurrencyData(name, price, volume);
                            CreateDataObject(data);

                            //Debug.Log("Found : " + name + " = " + float.Parse(price) + " at " + float.Parse(volume) + " sold");
                        });
                    });
                }
                dataLoaded = true;
            });
        }, delegate (string list) { //"name" will be equal to the name of the missing field.  In this case, "hits"
            Debug.LogWarning("no data found");
        });
    }
开发者ID:waltzaround,项目名称:CTEC608-Data-Visualisation,代码行数:35,代码来源:data.cs


示例10: OnPlayAvariable

    private void OnPlayAvariable(SocketIOEvent evt )
    {
        UserData player1 = CheckPlayer(evt.data.GetField("player1"));
        UserData player2 = CheckPlayer(evt.data.GetField("player2"));

        if( GameManager.Instance.userData.ID == player1.ID ){
            Debug.Log("Player1 Ready!!");
            GameManager.Instance.player = GameManager.Player.player1;

            JSONObject ready = new JSONObject();
            ready.AddField("id", player1.ID );
            NetworkManager.Instance.Socket.Emit("READY", ready);
        }else{
            if( GameManager.Instance.userData.ID == player2.ID ){
                Debug.Log("Player2 Ready!!");
                GameManager.Instance.player = GameManager.Player.player2;
                JSONObject ready = new JSONObject();
                ready.AddField("id", player1.ID );
                NetworkManager.Instance.Socket.Emit("READY", ready);
            }else{
                Debug.Log("JUST WATCH!!");
                GameManager.Instance.player = GameManager.Player.guest;
            }
        }

        oldText.text 		= player1.UserName;
        friendText.text 	= player2.UserName;
    }
开发者ID:shunlll999,项目名称:pong-unity,代码行数:28,代码来源:GameController.cs


示例11: fromJSONObject

	public void fromJSONObject(JSONObject json)
	{
		JSONObject marketItem = json.GetField("marketItem");

		JSONObject jsonProductId = marketItem.GetField("productId");
		if (jsonProductId != null) {
			this.productId = marketItem.GetField("productId").str;
		} else {
			this.productId = "";
		}
        
		JSONObject jsonIosId = marketItem.GetField ("iosId");

		this.useIos = (jsonIosId != null);
		if (this.useIos)
		{
			this.iosId = jsonIosId.str;
		}
		
		JSONObject jsonAndroidId = marketItem.GetField ("androidId");
		this.useAndroid = (jsonAndroidId != null);
		if (this.useAndroid)
		{
			this.androidId = jsonAndroidId.str;
		}
		
		this.price = marketItem.GetField ("price").f;
		this.consumable = (Consumable)int.Parse(marketItem.GetField("consumable").ToString());
	}
开发者ID:Bakiet,项目名称:UnityZombieCross,代码行数:29,代码来源:EconomyBuilderData.cs


示例12: ParseFrom

    public Dictionary<string, string> ParseFrom(string rawdata)
    {
        JSONObject jsonObj = new JSONObject(rawdata);
        Dictionary<string, string> data = jsonObj.ToDictionary();

        return data;
    }
开发者ID:rmarx,项目名称:ReverseRPG,代码行数:7,代码来源:LugusConfigDataHelper.cs


示例13: Buy

        /// <summary>
        /// Buys the purchasable virtual item.
        /// Implementation in subclasses will be according to specific type of purchase.
        /// </summary>
        /// <param name="payload">a string you want to be assigned to the purchase. This string
        /// is saved in a static variable and will be given bacl to you when the
        ///  purchase is completed.</param>
        /// <exception cref="Soomla.Store.InsufficientFundsException">throws InsufficientFundsException</exception>
        public override void Buy(string payload)
        {
            SoomlaUtils.LogDebug("SOOMLA PurchaseWithVirtualItem", "Trying to buy a " + AssociatedItem.Name + " with "
                                 + Amount + " pieces of " + TargetItemId);

            VirtualItem item = getTargetVirtualItem ();
            if (item == null) {
                return;
            }

            JSONObject eventJSON = new JSONObject();
            eventJSON.AddField("itemId", AssociatedItem.ItemId);
            StoreEvents.Instance.onItemPurchaseStarted(eventJSON.print(), true);

            if (!checkTargetBalance (item)) {
                StoreEvents.OnNotEnoughTargetItem(StoreInfo.VirtualItems["seed"]);
                return;
            //				throw new InsufficientFundsException (TargetItemId);
            }

            item.Take(Amount);

            AssociatedItem.Give(1);

            // We have to make sure the ItemPurchased event will be fired AFTER the balance/currency-changed events.
            StoreEvents.Instance.RunLater(() => {
                eventJSON = new JSONObject();
                eventJSON.AddField("itemId", AssociatedItem.ItemId);
                eventJSON.AddField("payload", payload);
                StoreEvents.Instance.onItemPurchased(eventJSON.print(), true);
            });
        }
开发者ID:amisiak7,项目名称:jewels2,代码行数:40,代码来源:PurchaseWithVirtualItem.cs


示例14: OSRICAttributeModel

    public OSRICAttributeModel(RPGCharacterModel _cm, JSONObject _jo)
    {
        cm = _cm;
        CharacterModifiers = new OSRICModifierCollection();
        characterName = _jo["characterName"].str;
        Str = (int)_jo["Str"].n;
        Dex = (int)_jo["Dex"].n;
        Con = (int)_jo["Con"].n;
        Int = (int)_jo["Int"].n;
        Wis = (int)_jo["Wis"].n;
        Cha = (int)_jo["Cha"].n;
        hitPoints = (int)_jo["hitPoints"].n;

        string[] levelStr = _jo["level"].str.Split('/');
        level = new int[levelStr.Length];

        for(int i=0; i<levelStr.Length; i++)
            level[i] = Int32.Parse(levelStr[i]);

        experiencePoints = (int)_jo["experiencePoints"].n;
        vision = (int)_jo["vision"].n;
        move = (int)_jo["move"].n;
        characterGender = OSRICConstants.GetEnum<OSRIC_GENDER>(_jo["characterGender"].str);
        characterRace = OSRICConstants.GetEnum<OSRIC_RACE>(_jo["characterRace"].str);
        characterClass = OSRICConstants.GetEnum<OSRIC_CLASS>(_jo["characterClass"].str);
        characterAlignment = OSRICConstants.GetEnum<OSRIC_ALIGNMENT>(_jo["characterAlignment"].str);
        characterState = OSRICConstants.GetEnum<OSRIC_CHARACTER_STATE>(_jo["characterState"].str);
        foreach(JSONObject obj in _jo["CharacterModifiers"].list)
            CharacterModifiers.Add(new OSRICCharacterModifier(obj));
    }
开发者ID:kingian,项目名称:osric_sandbox,代码行数:30,代码来源:OSRICAttributeModel.cs


示例15: SetResults

  public void SetResults(JSONObject jsonData) {
		spinDataResult = jsonData;
    resultsData = jsonData.GetArray("items");
    winningGold = jsonData.GetArray("wGold");
		// Calculate extra data (winning type, winning count from list result items)
		JSONObject extraData = SlotCombination.CalculateCombination(resultsData, GetNumLine());
    winningCount = extraData.GetArray("wCount");
    winningType = extraData.GetArray("wType");
		//
    isJackpot = jsonData.GetBoolean("isJP");
		freeSpinLeft = jsonData.GetInt("frLeft");
		isBigWin = jsonData.GetBoolean("bWin");
		gotFreeSpin = jsonData.GetInt("frCount") > 0;
		// bool[] winingItems = new bool[15];
		// for (int i = 0; i < winningGold.Length; i++) {
		// 	if (winningGold[i].Number > 0) {
		// 		for (int j = 0; j < SlotCombination.NUM_REELS; j++) {
		// 			winingItems[SlotCombination.COMBINATION[i, j]] = true;
		// 		}
		// 	}
		// }
    for (int i = 0; i < slotReels.Length; i++) {
      slotReels[i].SetResults(new int[3] { (int)resultsData[i * 3].Number, (int)resultsData[i * 3 + 1].Number, (int)resultsData[i * 3 + 2].Number });
    }
  }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:25,代码来源:SlotMachine.cs


示例16: GetValues

        public static JSONObject GetValues(string referenceId, string itemId)
        {
            var data = GetAccordionData(referenceId);
            var item = data.GetItem(itemId);

            JSONObject result = new JSONObject();
            result.AddValue("headline", item.Headline);
            result.AddValue("content", item.Content);

            result.AddValue("isRoot", item.Id == data.Id);

            if (item.Id == data.Id)
            {
                result.AddValue("canMoveUp", false);
                result.AddValue("canMoveDown", false);
            }
            else
            {
                var parent = item.Parent;
                var index = item.Parent.Items.IndexOf(item);
                result.AddValue("canMoveUp", index > 0);
                result.AddValue("canMoveDown", index < parent.Items.Count-1);
            }

            if (!string.IsNullOrEmpty(item.ModuleId))
            {
                var module = CmsService.Instance.GetItem<Entity>(new Id(item.ModuleId));
                if (module != null)
                {
                    result.AddValue("moduleId", item.ModuleId);
                    result.AddValue("moduleName", module.EntityName);
                }
            }
            return result;
        }
开发者ID:jeppe-andreasen,项目名称:Umbraco-Public,代码行数:35,代码来源:AccordionEditorHandler.aspx.cs


示例17: VirtualCurrencyPack

		/// <summary>
		/// see parent
		/// </summary>
		public VirtualCurrencyPack(JSONObject jsonItem)
			: base(jsonItem)
		{
			this.CurrencyAmount = System.Convert.ToInt32(((JSONObject)jsonItem[JSONConsts.CURRENCYPACK_CURRENCYAMOUNT]).n);
			
			CurrencyItemId = jsonItem[JSONConsts.CURRENCYPACK_CURRENCYITEMID].str;
		}
开发者ID:CoderBear,项目名称:AAUnity,代码行数:10,代码来源:VirtualCurrencyPack.cs


示例18: Node

 public Node(JSONObject json)
 {
     id = TrackGenerator.getByKey (json, "@id").i;
     lat = TrackGenerator.getByKey (json, "lat").n;
     lon = TrackGenerator.getByKey (json, "lon").n;
     ele = TrackGenerator.getByKey (json, "ele").n;
 }
开发者ID:zuehlke-ar,项目名称:camp-vr,代码行数:7,代码来源:TrackGenerator.cs


示例19:

 void ITmdbObject.ProcessJson(JSONObject jsonObject)
 {
     Id = (int)jsonObject.GetSafeNumber("id");
     BackdropPath = jsonObject.GetSafeString("backdrop_path");
     Name = jsonObject.GetSafeString("name");
     PosterPath = jsonObject.GetSafeString("poster_path");
 }
开发者ID:Fishes,项目名称:TMDbWrapper,代码行数:7,代码来源:CollectionSummary.cs


示例20: UpdateRowData

  public void UpdateRowData(JSONObject data, LeaderboardScreen.Tab selectedTab) {
    rowData = data;
    
    if (AccountManager.Instance.IsYou(rowData.GetString("username"))) {
      background.spriteName = "PopupBackground";
    } else {
      background.spriteName = "Global_Window_Paper";
    }
    
    playerNameLabel.text = rowData.GetString("displayName");
    if (selectedTab == LeaderboardScreen.Tab.TOP_RICHER) {
      cashLabel.text = rowData.GetLong("cash").ToString("N0") + "$";
    } else {
      // cashLabel.text = Utils.Localize("Top_Winner_Match_Text", new string[1] {rowData.GetInt("winMatchNumb").ToString("N0")});
      cashLabel.text = Localization.Format("Top_Winner_Match_Text", rowData.GetInt("bossKill").ToString("N0"));
    }
    rank = rowData.GetInt("rank");
    if (rank <= 3) {
			Utils.SetActive(rankBackground, false);
			Utils.SetActive(rankIcon.gameObject, true);
      rankIcon.spriteName = "Chat_RankIcon0" + rank;
    } else {
			Utils.SetActive(rankBackground, true);
			Utils.SetActive(rankIcon.gameObject, false);
      rankLabel.text = rank.ToString();
    }
    eventTrigger.inputParams = new object[] {rowData.GetString("username")};
    EventDelegate.Set(eventTrigger.onClick, delegate() { EventShowUserInfo((string)eventTrigger.inputParams[0]); });
  }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:29,代码来源:TopPlayerRowScript.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JSONReader类代码示例发布时间:2022-05-24
下一篇:
C# JSONNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap