本文整理汇总了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;
}
示例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;
}
}
}
示例3: LoadConfiguration
public void LoadConfiguration()
{
JSONObject configJSON = new JSONObject(loadConfigFile());
m_ConfigData = configJSON.ToDictionary();
}
示例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);
}
}
}
示例5: ProcessData
// 데이터 처리
private Dictionary<string, string> ProcessData(string jsonrawData)
{
JSONObject t = new JSONObject(jsonrawData);
return t.ToDictionary();
}
示例6: getResponse
public Dictionary<string, string> getResponse()
{
JSONObject json = new JSONObject(www.text);
Debug.Log("Response: " + www.text);
return json.ToDictionary();
}
示例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;
}
}
}