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


C# JSONObject.ToDictionary方法代码示例

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


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

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

示例2: PopulateBookshelf

  public IEnumerator PopulateBookshelf() {
    WWW curl = new WWW("https://rehgehstoy.firebaseio.com/books.json");

    yield return curl;

    Debug.Log(curl.text);
    if (!string.IsNullOrEmpty(curl.error)) {
      this.errorText.text = curl.error;
    } else {
      JSONObject jso = new JSONObject(curl.text);
      Dictionary<string, string> diccy = jso.ToDictionary();
      foreach (ShelfBook book in GameObject.FindObjectsOfType<ShelfBook>()) {
        if (diccy.ContainsKey(book.gameObject.name)) {
          book.bookText = Regex.Replace(diccy[book.gameObject.name], "%0D%0A", "\n");
        }
        book.GetComponent<Button>().interactable = true;
      }
    }
  }
开发者ID:mkapolka,项目名称:rehgehstoy,代码行数:19,代码来源:BookShelfManager.cs

示例3: LoadConfiguration

	public void LoadConfiguration()
	{
		JSONObject configJSON = new JSONObject(loadConfigFile());
		m_ConfigData = configJSON.ToDictionary();
	}
开发者ID:plafone,项目名称:TempleSaboteur,代码行数:5,代码来源:ConfigurationMgr.cs

示例4: ParseAccessToken

        private void ParseAccessToken(JSONObject parsed)
        {
            var dict = parsed.ToDictionary();
            foreach (KeyValuePair<string, string> kvp in dict)
            {
                if (kvp.Key == "access_token")
                {
                    _oAuth2.Token = kvp.Value;
                    PlayerPrefs.SetString("FitbitAccessToken", kvp.Value);
                }
                else if (kvp.Key == "expires_in")
                {
                    var num = 0;
                    Int32.TryParse(kvp.Value, out num);
                    _oAuth2.ExpiresIn = num;

                }
                else if (kvp.Key == "refresh_token")
                {
                    _oAuth2.RefreshToken = kvp.Value;
                    Debug.Log("REFRESH TOKEN: " + kvp.Value);
                    PlayerPrefs.SetString("FitbitRefreshToken", kvp.Value);
                    Debug.Log("Token We Just Store: " + PlayerPrefs.GetString("FitbitRefreshToken"));
                }
                else if (kvp.Key == "token_type")
                {
                    _oAuth2.TokenType = kvp.Value;
                    PlayerPrefs.SetString("FitbitTokenType", kvp.Value);
                }
            }
        }
开发者ID:TravisEvashkevich,项目名称:UnityFitbit,代码行数:31,代码来源:FitBitAPI.cs

示例5: ProcessData

 // 데이터 처리
 private Dictionary<string, string> ProcessData(string jsonrawData)
 {
     JSONObject t = new JSONObject(jsonrawData);
     return t.ToDictionary();
 }
开发者ID:Cube219,项目名称:BlockBuster,代码行数:6,代码来源:ServerManager.cs

示例6: getResponse

 public Dictionary<string, string> getResponse()
 {
     JSONObject json = new JSONObject(www.text);
         Debug.Log("Response: " + www.text);
         return json.ToDictionary();
 }
开发者ID:LeagueOfDevelopers,项目名称:Imaginarium,代码行数:6,代码来源:ServerDriver.cs

示例7: LOGINUser

    //---------------------------------------------------------------------
    //-------------------------  PUBLIC METHODS  --------------------------
    //---------------------------------------------------------------------

    // Use this to do a POST and create a session
    public IEnumerator LOGINUser(string email, string password)
    {
        bool allProper = false;
        int retryCount = NumberOfRetries;

        // First thing first - I need to do some cleanup of the email string
        // And I need to store those informations for other calls
        login_email = CleanInput(email);
        login_password = password;

        JSONObject nested_fields = new JSONObject(JSONObject.Type.OBJECT);
        nested_fields.AddField("email", login_email);
        nested_fields.AddField("password", login_password);
        JSONObject root_field = new JSONObject(JSONObject.Type.OBJECT);
        root_field.AddField("user", nested_fields);

        string encodedString = root_field.ToString();

        string result = "";

        while (!allProper && retryCount > 0)
        {
            // the actual call, in a try catch
            try
            {
                using (var client = new WebClient())
                {
                    client.Headers[HttpRequestHeader.ContentType] = "application/json";
                    result = client.UploadString(login_url, "POST", encodedString);
                }
                allProper = true;
            }
            catch (WebException ex)
            {
                retryCount--;

                if (retryCount == 0)
                {
                    Debug.Log("TESTexception: " + ex);
                    var response = ex.Response as HttpWebResponse;
                    errorHandler = RestError.GenericLoginError;

                    if (response != null)
                    {
                        Debug.Log("HTTP Status Code: " + (int)response.StatusCode);
                        switch ((int)response.StatusCode)
                        {

                            case 400:
                                errorHandler = RestError.WrongMail;
                                break;
                            case 401:
                                errorHandler = RestError.WrongPassword;
                                break;
                            case 500:
                                errorHandler = RestError.ServerError;
                                break;
                            default:
                                break;
                        }
                        break;
                    }
                }
            }
        }

        yield return result;

        if (allProper)
        {
            errorHandler = RestError.AllGood;

            Debug.Log(result);
            JSONObject j = new JSONObject(result);
            // this won't work everytime
            Dictionary<string, string> decoded_response = j.ToDictionary();
            token = decoded_response["token"];
            logged_user_complete_name = decoded_response["complete_name"];
            logged_user_id = decoded_response["id"];


            int sessionCounter = int.Parse(decoded_response["sessions_counter"]);

            if (sessionCounter > 0)
            {
                sessionsHandler = RestSession.MultipleActive;
            }
        }
    }
开发者ID:Sciandra-Leva,项目名称:rest-client-unity-test,代码行数:94,代码来源:NetworkREST.cs


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