Skip to content

Commit 8a74cb2

Browse files
committed
more JSON fixes for API consistency w/ the rest of processing.data.*
1 parent 09624dc commit 8a74cb2

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

core/src/processing/data/JSONArray.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@ public JSONObject getJSONObject(int index) {
392392
}
393393

394394

395+
/** Get this entire array as a String array. */
396+
public String[] getStringArray() {
397+
String[] outgoing = new String[size()];
398+
for (int i = 0; i < size(); i++) {
399+
outgoing[i] = getString(i);
400+
}
401+
return outgoing;
402+
}
403+
404+
395405
/** Get this entire array as an int array. Everything must be an int. */
396406
public int[] getIntArray() {
397407
int[] outgoing = new int[size()];
@@ -760,31 +770,31 @@ protected JSONArray append(Object value) {
760770

761771

762772
/**
763-
* Put or replace an int value. If the index is greater than the length of
773+
* Put or replace a String value. If the index is greater than the length of
764774
* the JSONArray, then null elements will be added as necessary to pad
765775
* it out.
766776
* @param index The subscript.
767-
* @param value An int value.
777+
* @param value A String value.
768778
* @return this.
769779
* @throws JSONException If the index is negative.
770780
*/
771-
public JSONArray setInt(int index, int value) {
772-
this.set(index, new Integer(value));
781+
public JSONArray setString(int index, String value) {
782+
this.set(index, value);
773783
return this;
774784
}
775785

776786

777787
/**
778-
* Put or replace a String value. If the index is greater than the length of
788+
* Put or replace an int value. If the index is greater than the length of
779789
* the JSONArray, then null elements will be added as necessary to pad
780790
* it out.
781791
* @param index The subscript.
782-
* @param value A String value.
792+
* @param value An int value.
783793
* @return this.
784794
* @throws JSONException If the index is negative.
785795
*/
786-
public JSONArray setString(int index, String value) {
787-
this.set(index, value);
796+
public JSONArray setInt(int index, int value) {
797+
this.set(index, new Integer(value));
788798
return this;
789799
}
790800

@@ -863,13 +873,13 @@ public JSONArray setBoolean(int index, boolean value) {
863873
// }
864874

865875

866-
public JSONArray setArray(int index, JSONArray value) {
876+
public JSONArray setJSONArray(int index, JSONArray value) {
867877
set(index, value);
868878
return this;
869879
}
870880

871881

872-
public JSONArray setObject(int index, JSONObject value) {
882+
public JSONArray setJSONObject(int index, JSONObject value) {
873883
set(index, value);
874884
return this;
875885
}
@@ -931,7 +941,7 @@ protected boolean isNull(int index) {
931941
* @return The value that was associated with the index,
932942
* or null if there was no value.
933943
*/
934-
public Object removeIndex(int index) {
944+
public Object remove(int index) {
935945
Object o = this.opt(index);
936946
this.myArrayList.remove(index);
937947
return o;

0 commit comments

Comments
 (0)