Пример #1
0
 /// <summary> Produce a JSONArray containing the names of the elements of this
 /// JSONObject.
 /// </summary>
 /// <returns> A JSONArray containing the key strings, or null if the JSONObject
 /// is empty.
 /// </returns>
 public virtual JSONArray names()
 {
     JSONArray ja = new JSONArray();
     System.Collections.IEnumerator keyIter = keys();
     while (keyIter.MoveNext())
     {
         ja.put(keyIter.Current);
     }
     return ja.length() == 0 ? null : ja;
 }
Пример #2
0
        public org.json.JSONArray getJSONArray(string name)
        {
            #if VERBOSE_LOGGING
            Debug.Log(MethodBase.GetCurrentMethod().Name);
            #endif
            JNIFind();
            if (_jcJsonObject == IntPtr.Zero)
            {
                Debug.LogError("_jcJsonObject is not initialized");
                return null;
            }
            if (_jmGetJsonArray == IntPtr.Zero)
            {
                Debug.LogError("_jmGetJsonArray is not initialized");
                return null;
            }

            IntPtr arg1 = AndroidJNI.NewStringUTF(name);
            IntPtr result = AndroidJNI.CallObjectMethod(_instance, _jmGetJsonArray, new jvalue[] { new jvalue() { l = arg1 } });
            AndroidJNI.DeleteLocalRef(arg1);

            if (result == IntPtr.Zero)
            {
                Debug.LogError("Failed to get JSONArray");
                return null;
            }

            org.json.JSONArray retVal = new JSONArray(result);
            return retVal;
        }
Пример #3
0
 /// <summary> Produce a JSONArray containing the values of the members of this
 /// JSONObject.
 /// </summary>
 /// <param name="names">A JSONArray containing a list of key strings. This
 /// determines the sequence of the values in the result.
 /// </param>
 /// <returns> A JSONArray of values.
 /// </returns>
 /// <throws>  JSONException If any of the values are non-finite numbers. </throws>
 public virtual JSONArray toJSONArray(JSONArray names)
 {
     if (names == null || names.length() == 0)
     {
         return null;
     }
     JSONArray ja = new JSONArray();
     for (int i = 0; i < names.length(); i += 1)
     {
         ja.put(this.opt(names.getString(i)));
     }
     return ja;
 }
Пример #4
0
 /// <summary> Produce a JSONObject by combining a JSONArray of names with the values
 /// of this JSONArray.
 /// </summary>
 /// <param name="names">A JSONArray containing a list of key strings. These will be
 /// paired with the values.
 /// </param>
 /// <returns> A JSONObject, or null if there are no names or if this JSONArray
 /// has no values.
 /// </returns>
 /// <throws>  JSONException If any of the names are null. </throws>
 public virtual JSONObject toJSONObject(JSONArray names)
 {
     if (names == null || names.length() == 0 || length() == 0)
     {
         return null;
     }
     JSONObject jo = new JSONObject();
     for (int i = 0; i < names.length(); i += 1)
     {
         jo.put(names.getString(i), this.opt(i));
     }
     return jo;
 }