private void HandleOnActionHistoryReceived(string sender, string actionHistory) { //DebugLog.LogWarning (actionHistory); JSON_Object obj = new JSON_Object(actionHistory); int roundStatus = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND_STATUS); int round = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND); JSONArray turnsArray = obj.getJSONArray(Constants.FIELD_ACTION_HISTORY_TURNS); for (int i = 0; i < turnsArray.Count(); i++) { ActionResponse ar = JsonUtility.FromJson <ActionResponse> (turnsArray.getString(i)); if (playerID.Equals(ar.Player_Name)) { betAmount += ar.Bet_Amount; buyInAmount = ar.Player_BuyIn_Chips; if (ar.Action == (int)PLAYER_ACTION.FOLD || ar.Action == (int)PLAYER_ACTION.TIMEOUT) { GetComponent <CanvasGroup> ().alpha = .4f; } } } DisplayBetAmount(); DisplayTotalChips(); }
// Use this for initialization void Start() { JSON_Object jo1 = new JSON_Object(); jo1.put("count", 1); jo1.increment("count"); Debug.Log("Should print 2: " + jo1.getInt("count")); JSON_Object jo2 = new JSON_Object("{\"quote\": \"He said, \\\"I like JSON\\\"\"}"); Debug.Log("Should print an escaped quote: " + jo2.toString()); JSONArray ja1 = new JSONArray(); ja1.put(jo1); ja1.put(jo2); Debug.Log("Should print count 2, and an escaped quote: " + ja1.toString()); JSON_Object jo3 = ja1.getJSONObject(1); Debug.Log("Should print the same escaped quote: " + jo3.toString()); string twitterTest = "{\"errors\": [{\"message\": \"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.\", \"code\": 68}]}"; JSON_Object jo4 = new JSON_Object(twitterTest); JSONArray ja2 = jo4.getJSONArray("errors"); string message = ja2.getJSONObject(0).getString("message"); int code = ja2.getJSONObject(0).getInt("code"); Debug.Log(message + " code: " + code); }
private void manageGameCompleted(string sender, string msg) { // DEBUG.Log ("Game Completed : "+msg); JSON_Object jsonResponce = new JSON_Object(msg); List <string> listBestCard = new List <string> (); JSONArray jSONArray = jsonResponce.getJSONArray(GameConstant.TAG_WINNER_BEST_CARDS); for (int i = 0; i < jSONArray.Count(); i++) { listBestCard.Add(jSONArray.get(i).ToString()); } if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.manageGameFinishAction( jsonResponce.getString(GameConstant.TAG_WINNER_NAME), jsonResponce.getInt(GameConstant.TAG_WINNER_RANK), jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT), jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), listBestCard); } else { waGameManager.manageGameFinishAction( jsonResponce.getString(GameConstant.TAG_WINNER_NAME), jsonResponce.getInt(GameConstant.TAG_WINNER_RANK), jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT), listBestCard); // jsonResponce.getInt (GameConstant.TAG_WINNERS_WINNING_AMOUNT), } }
private void generateWinnerPlayers(string sender, string winnerDetails) { DEBUG.Log("Winner Data : " + winnerDetails); JSONArray jsonResponceArray; JSONArray waPotResponceArray = null; if (sender.Equals(appwarp.WA_SERVER_NAME)) { JSON_Object jsonObject = new JSON_Object(winnerDetails); jsonResponceArray = jsonObject.getJSONArray("Table_Pot"); waPotResponceArray = jsonObject.getJSONArray("WA_Pot"); } else { jsonResponceArray = new JSONArray(winnerDetails); } StartCoroutine(winnerBrodcast(sender, jsonResponceArray, waPotResponceArray)); }
public API_TournamentRegPlayers(string tourPlayers) { JSON_Object obj = new JSON_Object(tourPlayers); id = obj.getString("id"); game_name = obj.getString("game_name"); poker_type = obj.getString("poker_type"); JSONArray playerArr = obj.getJSONArray("users"); playerList = new List <SingleGameInfoPlayer> (); for (int i = 0; i < playerArr.Count(); i++) { playerList.Add(JsonUtility.FromJson <SingleGameInfoPlayer> (playerArr.getString(i))); } }
/// <summary> /// Raises the login response received event. /// </summary> /// <param name="www">Www.</param> private void OnLoginResponseReceived(WWW www) { UIManager.Instance.loader.gameObject.SetActive(false); debugString += "\n" + www.text; if (www.error != null) { DebugLog.LogError(www.error); UIManager.Instance.loginPanel.txtError.text = "<color=yellow>Something went wrong.</color>"; DebugLog.Log(www.text); JSON_Object errorObj = new JSON_Object(www.text); if (errorObj.has("messages")) { JSONArray arr = errorObj.getJSONArray("messages"); if (arr.Count() > 0) { UIManager.Instance.loginPanel.txtError.text = "<color=yellow>" + arr.getString(0) + "</color>"; } } return; } DebugLog.LogWarning(www.text); JSON_Object obj = new JSON_Object(www.text); if (obj.getString("status").Equals(APIConstants.STATUS_AUTHORIZED)) { API_LoginPlayerInfo loggedInPlayerInfo = new API_LoginPlayerInfo(www.text); LoginScript.loggedInPlayer = loggedInPlayerInfo; // GetProfileImage (loggedInPlayerInfo.avtar); APIConstants.PLAYER_TOKEN = loggedInPlayerInfo.token; // UIManager.Instance.loginPanel.gameObject.SetActive (false); UIManager.Instance.lobbyPanel.gameObject.SetActive(true); GetPlayerInfo(); StartUpdatingLoginStatus(); } else { UIManager.Instance.loginPanel.txtError.text = "<color=red>Something went wrong.</color>"; } }
/// <summary> /// Initializes a new instance of the <see cref="API_Transactions"/> class. /// </summary> /// <param name="transactions">Transactions.</param> public API_Transactions(string transactions) { JSON_Object obj = new JSON_Object(transactions); total = obj.getInt("total"); total = obj.getInt("per_page"); total = obj.getInt("current_page"); total = obj.getInt("last_page"); next_page_url = obj.getString("next_page_url"); prev_page_url = obj.getString("prev_page_url"); from = obj.getString("from"); to = obj.getString("to"); JSONArray arr = obj.getJSONArray("data"); transactionList = new List <Transactions> (); for (int i = 0; i < arr.Count(); i++) { // transactionList.Add (new Transactions (arr.getString (i))); transactionList.Add(JsonUtility.FromJson <Transactions> (arr.getString(i))); } }