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

C# JSONArray类代码示例

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

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



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

示例1: Init

  public override void Init(object[] data) {
    base.Init(data);
    List<Buddy> buddyList = SmartfoxClient.Instance.GetBuddyList();
    if (buddyList.Count > 0) {
      Utils.SetActive(noFriendLabel, false);
      EventDelegate.Set(btnSendInvite.onClick, EventSendInvite);
			JSONObject friend;
			friendList = new JSONArray();
			for (int i = 0; i < buddyList.Count; i++) {
				friend = new JSONObject();
				if (buddyList[i].IsOnline) {
					friend.Add("displayName", buddyList[i].GetVariable("displayName").GetStringValue());
					friend.Add("cash", (long)buddyList[i].GetVariable("cash").GetDoubleValue());
					friend.Add("username", buddyList[i].Name);
					friendList.Add(friend);
				}
			}
			InitScrollViewData(friendList);
    } else {
			// TO DO - dont have friend message
      Utils.SetActive(scrollview.gameObject, false);
      Utils.SetActive(btnSendInvite.gameObject, false);
      Utils.SetActive(noFriendLabel, true);
      Debug.Log("----------- DONE HAVE ANY FRIEND ----------------");
    }
  }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:26,代码来源:PopupInviteToGame.cs


示例2: LoadFriendRank

    public void LoadFriendRank(Action callback)
    {
        JSONArray friendList = new JSONArray ();

        foreach(JSONValue item in UserSingleton.Instance.FriendList){
            JSONObject friend = item.Obj;
            friendList.Add (friend ["id"]);
        }

        JSONObject requestBody = new JSONObject ();
        requestBody.Add ("UserID", UserSingleton.Instance.UserID);
        requestBody.Add ("FriendList", friendList);

        HTTPClient.Instance.POST (Singleton.Instance.HOST + "/Rank/Friend", requestBody.ToString(), delegate(WWW www) {

            Debug.Log("LoadFriendRank" + www.text);

            string response = www.text;

            JSONObject obj = JSONObject.Parse(response);

            JSONArray arr = obj["Data"].Array;

            foreach(JSONValue item in arr){
                int rank = (int)item.Obj["Rank"].Number;
                if(FriendRank.ContainsKey(rank)){
                    FriendRank.Remove(rank);
                }
                FriendRank.Add(rank,item.Obj);
            }

            callback();

        });
    }
开发者ID:chris-chris,项目名称:Chapter22,代码行数:35,代码来源:RankSingleton.cs


示例3: ShouldLoadData

 private bool ShouldLoadData(Tab selectedTab) {
   JSONArray checkData = new JSONArray();
   DateTime? checkTime = null;
   switch(selectedTab) {
     case Tab.TOP_RICHER:
       checkData = topRicherList;
       checkTime = topRicherLoadTime;
     break;
     case Tab.TOP_WINNER:
       checkData = topWinnerList;
       checkTime = topWinnerLoadTime;
     break;
     default:
     return false;
   }
   
   if (checkData == null || checkData.Length == 0) {
     return true;
   } else {
     if (checkTime.HasValue) {
       if (Utils.CurrentTime().Subtract((DateTime)checkTime).TotalSeconds >= RELOAD_DATA_SECONDS) {
         return true;
       } else {
         return false;
       }
     } else {
       return true;
     }
   }
 }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:30,代码来源:LeaderboardScreen.cs


示例4: Init

  public override void Init(object[] data) {
    base.Init(data);
    EventDelegate.Set(tabInvite.onClick, EventTabInvite);
    EventDelegate.Set(tabFriends.onClick, EventTabFriends);
		
		// Get list friends from smartfox buddy list
    List<Buddy> buddyList = SmartfoxClient.Instance.GetBuddyList();
    if (buddyList.Count > 0) {
			JSONObject friend;
			friendList = new JSONArray();
			for (int i = 0; i < buddyList.Count; i++) {
				friend = new JSONObject();
				if (buddyList[i].IsOnline) {
					friend.Add("displayName", buddyList[i].GetVariable("displayName").GetStringValue());
					friend.Add("cash", (long)buddyList[i].GetVariable("cash").GetDoubleValue());
					friend.Add("avatar", buddyList[i].GetVariable("avatar").GetStringValue());
					friend.Add("facebookId", buddyList[i].GetVariable("facebookId").GetStringValue());
				} else {
					friend.Add("displayName", buddyList[i].GetVariable("$displayName").GetStringValue());
					friend.Add("cash", (long)buddyList[i].GetVariable("$cash").GetDoubleValue());
					friend.Add("avatar", buddyList[i].ContainsVariable("$avatar") ? buddyList[i].GetVariable("$avatar").GetStringValue() : string.Empty);
					friend.Add("facebookId", buddyList[i].ContainsVariable("$facebookId") ? buddyList[i].GetVariable("$facebookId").GetStringValue() : string.Empty);
				}
				friend.Add("username", buddyList[i].Name);
				friendList.Add(friend);
			}
			InitScrollViewData(friendList);
    } else {
      Utils.SetActive(scrollview.gameObject, false);
      Debug.Log("----------- DONE HAVE ANY FRIEND ----------------");
    }
  }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:32,代码来源:PopupFriends.cs


示例5: decodeArray

        public JSONArray decodeArray(string str, ref int index)
        {
            if (str[index] != '[') return null;
            index++;
            JSONArray array = new JSONArray();
            bool array_should_over = false;
            while (index < str.Length)
            {
                index = passWhiteSpace(str, index);
                if (str[index] == ']')
                {
                    index++;
                    return array;
                }
                else if (array_should_over)
                {

                    throw new JSONError(str, index);
                }
                array.addJSONValue(decodeValue(str, ref index));
                index = passWhiteSpace(str, index);
                if (str[index] != ',')
                {
                    array_should_over = true;
                }
                else
                {
                    index++;
                }

            }

            return null;
        }
开发者ID:swordow,项目名称:SimpleJSON,代码行数:34,代码来源:SharpJSON.cs


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


示例7: SerializeArray

 public static string SerializeArray(JSONArray jsonArray)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("[");
     for (int i = 0; i < jsonArray.Count; i++)
     {
         if (jsonArray[i] is JSONObject)
         {
             builder.Append(string.Format("{0},", SerializeObject((JSONObject) jsonArray[i])));
         }
         else if (jsonArray[i] is JSONArray)
         {
             builder.Append(string.Format("{0},", SerializeArray((JSONArray) jsonArray[i])));
         }
         else if (jsonArray[i] is string)
         {
             builder.Append(string.Format("{0},", jsonArray[i]));
         }
         else
         {
             builder.Append(string.Format("{0},", jsonArray[i]));
         }
     }
     if (builder.Length > 1)
     {
         builder.Remove(builder.Length - 1, 1);
     }
     builder.Append("]");
     return builder.ToString();
 }
开发者ID:SoMeTech,项目名称:SoMeRegulatory,代码行数:30,代码来源:JSONConvert.cs


示例8: JSONValue

        /// <summary>
        ///     Construct a copy of the JSONValue given as a parameter
        /// </summary>
        /// <param name="value"></param>
        public JSONValue(JSONValue value)
        {
            Type = value.Type;
            switch (Type)
            {
                case JSONValueType.String:
                    Str = value.Str;
                    break;

                case JSONValueType.Boolean:
                    Boolean = value.Boolean;
                    break;

                case JSONValueType.Number:
                    Number = value.Number;
                    break;

                case JSONValueType.Object:
                    if (value.Obj != null)
                        Obj = new JSONObject(value.Obj);
                    break;

                case JSONValueType.Array:
                    Array = new JSONArray(value.Array);
                    break;
            }
        }
开发者ID:jporter19,项目名称:TeamStyle16_3D,代码行数:31,代码来源:JSONValue.cs


示例9: Init

 public override void Init(object[] data) {
   gameType = (BaseGameScreen.GameType)data[0];
   EventDelegate.Set(btnBack.onClick, BackToSelectGame);
   EventDelegate.Set(btnCreateRoom.onClick, OpenPopupCreateRoom);
   // fake room list
   // roomList = new JSONArray();
   roomList = ((JSONObject)data[1]).GetArray("rooms");
   Debug.Log(roomList.ToString());
   // fake room min bet
   // int[] roomBet = new int[] { 10000, 100000, 520000, 2000000};
   // for (int i = 0; i < roomList.Length; i++) {
   //   JSONObject room = roomList[i].Obj;
   //   room.Add("id", i);
   //   room.Add("name", "room " + i);
   //   room.Add("minBet", roomBet[i % 4]);
   //   // roomList.Add(room);
   // }
   InitScrollViewData();
   // Set Bet Filter
   for (int i = 0; i < betFilterList.Length; i++) {
     betFilterPopupList.items.Add(betFilterList[i]);
   }
   EventDelegate.Set(betFilterPopupList.onChange, EventFilterBet);
   crtBetFilter = betFilterList[0];
 }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:25,代码来源:SelectRoomScreen.cs


示例10: Start

    // Use this for initialization
    void Start()
    {
        Debug.Log ("Loading credits file");
        creditsAsset = Resources.Load ("Credits") as TextAsset;
        creditsJson = JSON.Parse (creditsAsset.text) as JSONArray;

        Invoke ("ShowCredits", 2f);
    }
开发者ID:hannahjgb,项目名称:AdventureGameFiles,代码行数:9,代码来源:CreditsPanel.cs


示例11: ExportData

    public static JSONArray ExportData(this List<int> list)
    {
        var json_array = new JSONArray();

        foreach (var num in list)
            json_array.Add(num);

        return json_array;
    }
开发者ID:jporter19,项目名称:TeamStyle16_3D,代码行数:9,代码来源:TextFxHelperMethods.cs


示例12: ToJSON

 public JSONValue ToJSON()
 {
     var result = new JSONArray();
     foreach (var item in this.Items)
     {
         result.AddValue(item.ToObject());
     }
     return result;
 }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:9,代码来源:AccordionData.cs


示例13: setChatterArray

    public void setChatterArray(JSONArray records)
    {
        chatterArray = records;
        chatterFetched = true;

        if (records.Length > 0) {
            enableChatter();
        }
    }
开发者ID:CodeScience,项目名称:VRpportunity,代码行数:9,代码来源:WindowHandler.cs


示例14: ProcessSwungMens

	/// <summary> Synchronise les SwungMens acheté et achetable </summary>
	private static void ProcessSwungMens(JSONArray array)
    {
		Settings.Instance.ResetDefaultPlayer ();
		foreach (JSONValue value in array)
        {
			Player p = new Player (value.Obj);
			Settings.Instance.AddOrUpdate_Player (p);
			if (!Settings.Instance.Default_player.ContainsKey (p.UID))
				Settings.Instance.Default_player.Add (p.UID, p);
        }
    }
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:12,代码来源:User.cs


示例15: create

 public static Property_int create(JSONArray template)
 {
     switch (template.getString(0))
     {
         case "mul": return new Property_Mul(template);
         case "add": return new Property_Add(template);
         case "count": return new Property_Count(template.getArray(1));
         case "amountOf": return new Property_AmountOf(ResourceType.get(template.getString(1)));
         default: throw new ArgumentException("Invalid property " + template.getString(0));
     }
 }
开发者ID:LaurieCheers,项目名称:MagicChessPuzzles,代码行数:11,代码来源:Property.cs


示例16: Friends

 public Friends(JSONArray array)
 {
     this.friends = new Dictionary<string, User>();//new User[friends.Length];
     foreach (JSONValue friend in array)
     {
         User friend_user = new User();
         friend_user.update(friend.Obj);
         friend_user.is_connected = false;
         this.friends.Add(friend_user.username, friend_user);
     }
 }
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:11,代码来源:Friends.cs


示例17: Initialize

    void Initialize(int id, string question, int correct, JSONArray answers)
    {
        this._id = id;
        this._question = question;
        this._correct = correct;

        this._answers = new List <Answer> ();
        foreach (JSONNode answer in answers) {
            this._answers.Add (new Answer(answer));
        }
    }
开发者ID:santiiiii,项目名称:AulaVirtual2,代码行数:11,代码来源:Question.cs


示例18: Start

    // Use this for initialization
    void Start()
    {
        string format = "yyyyMMdd-hhmm";
        outputPath = "Assets/Resources/"  + outputFileName + "-" + DateTime.Now.ToString (format);
        if (File.Exists (outputPath)) {
            Debug.Log ("ERROR: " + outputPath + " already exists");
            return;
        }

        bookmarks = new JSONArray ();
    }
开发者ID:mdrouhard,项目名称:gaze-interaction-test,代码行数:12,代码来源:BookmarkWriter.cs


示例19: createList

 public static List<TriggeredAbility> createList(JSONArray listTemplate)
 {
     List<TriggeredAbility> result = new List<TriggeredAbility>();
     if (listTemplate != null)
     {
         foreach (JSONArray template in listTemplate.asJSONArrays())
         {
             result.Add(new TriggeredAbility(template));
         }
     }
     return result;
 }
开发者ID:LaurieCheers,项目名称:MagicChessPuzzles,代码行数:12,代码来源:Trigger.cs


示例20: SetData

 public static void SetData(JSONArray users, Tab selectedTab) {
   switch(selectedTab) {
     case Tab.TOP_RICHER:
       topRicherList = users;
       topRicherLoadTime = Utils.CurrentTime();
     break;
     case Tab.TOP_WINNER:
       topWinnerList = users;
       topWinnerLoadTime = Utils.CurrentTime();
     break;
   }
 }
开发者ID:markofevil3,项目名称:SlotMachine,代码行数:12,代码来源:LeaderboardScreen.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# JSONCollection类代码示例发布时间:2022-05-24
下一篇:
C# JSNode类代码示例发布时间: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