A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with commas separating the values. The internal form is an object having get and opt methods for accessing the values by index, and put methods for addin
| 98 | * @see PApplet#saveJSONArray(JSONArray, String) |
| 99 | */ |
| 100 | public class JSONArray { |
| 101 | |
| 102 | /** |
| 103 | * The arrayList where the JSONArray's properties are kept. |
| 104 | */ |
| 105 | private final ArrayList<Object> myArrayList; |
| 106 | |
| 107 | |
| 108 | /** |
| 109 | * Construct an empty JSONArray. |
| 110 | */ |
| 111 | public JSONArray() { |
| 112 | this.myArrayList = new ArrayList<>(); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | /** |
| 117 | * @nowebref |
| 118 | */ |
| 119 | public JSONArray(Reader reader) { |
| 120 | this(new JSONTokener(reader)); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /** |
| 125 | * Construct a JSONArray from a JSONTokener. |
| 126 | * |
| 127 | * @param x A JSONTokener |
| 128 | * @throws RuntimeException If there is a syntax error. |
| 129 | * @nowebref |
| 130 | */ |
| 131 | protected JSONArray(JSONTokener x) { |
| 132 | this(); |
| 133 | if (x.nextClean() != '[') { |
| 134 | throw new RuntimeException("A JSONArray text must start with '['"); |
| 135 | } |
| 136 | if (x.nextClean() != ']') { |
| 137 | x.back(); |
| 138 | for (;;) { |
| 139 | if (x.nextClean() == ',') { |
| 140 | x.back(); |
| 141 | myArrayList.add(JSONObject.NULL); |
| 142 | } else { |
| 143 | x.back(); |
| 144 | myArrayList.add(x.nextValue()); |
| 145 | } |
| 146 | switch (x.nextClean()) { |
| 147 | case ';': |
| 148 | case ',': |
| 149 | if (x.nextClean() == ']') { |
| 150 | return; |
| 151 | } |
| 152 | x.back(); |
| 153 | break; |
| 154 | case ']': |
| 155 | return; |
| 156 | default: |
| 157 | throw new RuntimeException("Expected a ',' or ']'"); |
nothing calls this directly
no outgoing calls
no test coverage detected