Пример #1
0
 /// <summary>
 /// Same as the get version of this same function, but does not log errors on failure
 /// </summary>
 /// <returns>
 /// The casted object. Returns the default value you specify if the conversion is not possible, or the index is out of bounds.
 /// </returns>
 /// <param name='index'>
 /// Index.
 /// </param>
 /// <param name='defaultValue'>
 /// The default value to return on failure.
 /// </param>
 public string optString(int index, string defaultValue)
 {
     if (index < arrayList.Count)
     {
         object obj = arrayList[index];
         if (obj is string)
         {
             return(JSON_Object.unquote((string)obj));
         }
         return(obj.ToString());
     }
     return(defaultValue);
 }
Пример #2
0
 /// <summary>
 /// Same as the get version of this same function, but does not log errors on failure
 /// </summary>
 /// <param name='index'>
 /// Index.
 /// </param>
 public System.Object opt(int index)
 {
     if (index < arrayList.Count)
     {
         System.Object value;
         value = arrayList[index];
         if (value is string)
         {
             return(JSON_Object.unquote((string)value));
         }
         return(value);
     }
     return(new System.Object());
 }
Пример #3
0
 /// <summary>
 /// Get the object in the array specified index.
 /// </summary>
 /// <param name='index'>
 /// Index.
 /// </param>
 public System.Object get(int index)
 {
     if (index < arrayList.Count)
     {
         System.Object value;
         value = arrayList[index];
         if (value is string)
         {
             return(JSON_Object.unquote((string)value));
         }
         return(value);
     }
     Debug.LogError("JSONArray.cs get(): index " + index + " out of range " + arrayList.Count);
     return(null);
 }
Пример #4
0
    /// <summary>
    /// Get the casted object in the array at the specified index.
    /// </summary>
    /// <returns>
    /// The casted object. Returns a default value and logs the error if the conversion is not possible, or the index is out of bounds.
    /// </returns>
    /// <param name='index'>
    /// Index.
    /// </param>
    public JSON_Object getJSONObject(int index)
    {
        if (index < arrayList.Count)
        {
            System.Object obj = arrayList[index];
            if (obj is JSON_Object)
            {
                return((JSON_Object)obj);
            }
            else if (obj is string)
            {
                return(new JSON_Object(JSON_Object.unquote((string)obj)));
            }
            Debug.LogError("JSONArray.cs getJSONObject() failed cast with index " + index);
            return(new JSON_Object());
        }

        Debug.LogError("JSONArray.cs getJSONObject(): index " + index + " out of range " + arrayList.Count);
        return(new JSON_Object());
    }