@@ -151,14 +151,15 @@ public JSONArray(String source) throws JSONException {
151151 * @param collection A Collection.
152152 */
153153 public JSONArray (Collection collection ) {
154- super ();
155- // this.myArrayList = new ArrayList();
156- if (collection != null ) {
157- Iterator iter = collection .iterator ();
158- while (iter .hasNext ()) {
159- super .add (JSONObject .wrap (iter .next ()));
160- }
161- }
154+ super ((collection == null )?new ArrayList ():collection );
155+ // if(collection == null)collection = new ArrayList();
156+ //// this.myArrayList = new ArrayList();
157+ // if (collection != null) {
158+ // Iterator iter = collection.iterator();
159+ // while (iter.hasNext()) {
160+ // super.add(JSONObject.wrap(iter.next()));
161+ // }
162+ // }
162163 }
163164
164165
@@ -633,6 +634,7 @@ public JSONArray put(long value) {
633634 * @return this.
634635 */
635636 public JSONArray put (Map value ) {
637+ if (value == null )value = new JSONObject ();
636638 super .add (new JSONObject (value ));
637639 return this ;
638640 }
@@ -682,7 +684,7 @@ public JSONArray put(int index, Collection value) throws JSONException {
682684 throw new JSONException ("JSONArray[" + index + "] not found." );
683685 }
684686 if (index < this .length ()) {
685- super .set (index , value );
687+ super .set (index , new JSONArray ( value ) );
686688 } else {
687689 while (index != this .length ()) {
688690 this .put (JSONObject .NULL );
@@ -754,7 +756,7 @@ public JSONArray put(int index, Map value) throws JSONException {
754756 throw new JSONException ("JSONArray[" + index + "] not found." );
755757 }
756758 if (index < this .length ()) {
757- super .set (index , value );
759+ super .set (index , new JSONObject ( value ) );
758760 } else {
759761 while (index != this .length ()) {
760762 this .put (JSONObject .NULL );
0 commit comments