Assets/Watson/Scripts/Utilities/Config.cs
/// <summary>
/// Parses a BlueMix json credentials into this object.
/// </summary>
/// <param name="json">The JSON data to parse.</param>
/// <returns>Returns true on success.</returns>
Parses a BlueMix json credentials into this object.
Parses a BlueMix json credentials into this object .
public bool ParseJSON(string json)
            {
                try
                {
                    IDictionary iParse = Json.Deserialize(json) as IDictionary;
                    IDictionary iCredentials = iParse["credentials"] as IDictionary;
                    m_URL = (string)iCredentials["url"];
                    m_User = (string)iCredentials["username"];
                    m_Password = (string)iCredentials["password"];
                    m_Note = (string)iCredentials["note"];
                    if(!string.IsNullOrEmpty((string)iCredentials["apikey"]))
                        m_Apikey = (string)iCredentials["apikey"];
                    if(!string.IsNullOrEmpty((string)iCredentials["api_key"]))
                        m_Apikey = (string)iCredentials["api_key"];
                    return true;
                }
                catch (Exception e)
                {
					try
					{
						IDictionary iParse = Json.Deserialize(json) as IDictionary;
						m_URL = (string)iParse["url"];
						m_User = (string)iParse["username"];
						m_Password = (string)iParse["password"];
						m_Note = (string)iParse["note"];
						if (!string.IsNullOrEmpty((string)iParse["apikey"]))
							m_Apikey = (string)iParse["apikey"];
						if (!string.IsNullOrEmpty((string)iParse["api_key"]))
							m_Apikey = (string)iParse["api_key"];
						return true;
					}
					catch
					{
						Log.Error("Config", "Caught Exception: {0}", e.ToString());
					}
					Log.Error("Config", "Caught Exception: {0}", e.ToString());
                }
                return false;
            }
public bool ParseJSON ( string json ) { try { IDictionary iParse = Json . Deserialize ( json ) as IDictionary ; IDictionary iCredentials = iParse [ " " ] as IDictionary ; m_URL = ( string ) iCredentials [ " " ] ; m_User = ( string ) iCredentials [ " " ] ; m_Password = ( string ) iCredentials [ " " ] ; m_Note = ( string ) iCredentials [ " " ] ; if ( ! string . IsNullOrEmpty ( ( string ) iCredentials [ " " ] ) ) m_Apikey = ( string ) iCredentials [ " " ] ; if ( ! string . IsNullOrEmpty ( ( string ) iCredentials [ " " ] ) ) m_Apikey = ( string ) iCredentials [ " " ] ; return true ; } catch ( Exception e ) { try { IDictionary iParse = Json . Deserialize ( json ) as IDictionary ; m_URL = ( string ) iParse [ " " ] ; m_User = ( string ) iParse [ " " ] ; m_Password = ( string ) iParse [ " " ] ; m_Note = ( string ) iParse [ " " ] ; if ( ! string . IsNullOrEmpty ( ( string ) iParse [ " " ] ) ) m_Apikey = ( string ) iParse [ " " ] ; if ( ! string . IsNullOrEmpty ( ( string ) iParse [ " " ] ) ) m_Apikey = ( string ) iParse [ " " ] ; return true ; } catch { Log . Error ( " " , " " , e . ToString ( ) ) ; } Log . Error ( " " , " " , e . ToString ( ) ) ; } return false ; }
Parses a BlueMix json credentials into this object.
Parses a BlueMix json credentials into this object .
Returns true on success.
Returns true on success .
json
string
The JSON data to parse.
The JSON data to parse .