Ejemplo 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;
 }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 07JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Produce a JSONArray containing the names of the elements of this
         * JSONObject.
         * @return A JSONArray containing the key strings, or null if the JSONObject
         * is empty.
         */
        public JSONArray Names()
        {
            var ja = new JSONArray();
            var keyset = Keys();
            foreach (var o in keyset)
            {
                ja.Put(o);
            }

            return ja.Length() == 0 ? null : ja;
        }