Esempio n. 1
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 07JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Produce a JSONArray containing the values of the members of this
  * JSONObject.
  * @param names A JSONArray containing a list of key strings. This
  * determines the sequence of the values in the result.
  * @return A JSONArray of values.
  * @throws JSONException If any of the values are non-finite numbers.
  */
 public JSONArray ToJSONArray(JSONArray names)
 {
     if (names == null || names.Length() == 0)
     {
         return null;
     }
     var ja = new JSONArray();
     for (var i = 0; i < names.Length(); i += 1)
     {
         ja.Put(Opt(names.GetString(i)));
     }
     return ja;
 }
Esempio n. 2
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 07JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Produce a JSONObject by combining a JSONArray of names with the values
  * of this JSONArray.
  * @param names A JSONArray containing a list of key strings. These will be
  * paired with the values.
  * @return A JSONObject, or null if there are no names or if this JSONArray
  * has no values.
  * @ If any of the names are null.
  */
 public JSONObject ToJSONObject(JSONArray names)
 {
     if (names == null || names.Length() == 0 || Length() == 0)
     {
         return null;
     }
     var jo = new JSONObject();
     for (int i = 0; i < names.Length(); i += 1)
     {
         jo.Put(names.GetString(i), Opt(i));
     }
     return jo;
 }