@@ -1230,7 +1230,7 @@ public Object optQuery(String jsonPointer) {
12301230 * Queries and returns a value from this object using {@code jsonPointer}, or
12311231 * returns null if the query fails due to a missing key.
12321232 *
1233- * @param The JSON pointer
1233+ * @param jsonPointer The JSON pointer
12341234 * @return the queried value or {@code null}
12351235 * @throws IllegalArgumentException if {@code jsonPointer} has invalid syntax
12361236 */
@@ -1323,8 +1323,9 @@ public JSONObject toJSONObject(JSONArray names) throws JSONException {
13231323 * whitespace is added. If it is not possible to produce a syntactically
13241324 * correct JSON text then null will be returned instead. This could occur if
13251325 * the array contains an invalid number.
1326- * <p>
1326+ * <p><b>
13271327 * Warning: This method assumes that the data structure is acyclical.
1328+ * </b>
13281329 *
13291330 * @return a printable, displayable, transmittable representation of the
13301331 * array.
@@ -1339,9 +1340,24 @@ public String toString() {
13391340 }
13401341
13411342 /**
1342- * Make a pretty-printed JSON text of this JSONArray. Warning: This method
1343- * assumes that the data structure is acyclical.
1344- *
1343+ * Make a pretty-printed JSON text of this JSONArray.
1344+ *
1345+ * <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
1346+ * one element, then the array will be output on a single line:
1347+ * <pre>{@code [1]}</pre>
1348+ *
1349+ * <p>If an array has 2 or more elements, then it will be output across
1350+ * multiple lines: <pre>{@code
1351+ * [
1352+ * 1,
1353+ * "value 2",
1354+ * 3
1355+ * ]
1356+ * }</pre>
1357+ * <p><b>
1358+ * Warning: This method assumes that the data structure is acyclical.
1359+ * </b>
1360+ *
13451361 * @param indentFactor
13461362 * The number of spaces to add to each level of indentation.
13471363 * @return a printable, displayable, transmittable representation of the
@@ -1360,8 +1376,9 @@ public String toString(int indentFactor) throws JSONException {
13601376 /**
13611377 * Write the contents of the JSONArray as JSON text to a writer. For
13621378 * compactness, no whitespace is added.
1363- * <p>
1379+ * <p><b>
13641380 * Warning: This method assumes that the data structure is acyclical.
1381+ *</b>
13651382 *
13661383 * @return The writer.
13671384 * @throws JSONException
@@ -1371,10 +1388,23 @@ public Writer write(Writer writer) throws JSONException {
13711388 }
13721389
13731390 /**
1374- * Write the contents of the JSONArray as JSON text to a writer. For
1375- * compactness, no whitespace is added.
1376- * <p>
1391+ * Write the contents of the JSONArray as JSON text to a writer.
1392+ *
1393+ * <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
1394+ * one element, then the array will be output on a single line:
1395+ * <pre>{@code [1]}</pre>
1396+ *
1397+ * <p>If an array has 2 or more elements, then it will be output across
1398+ * multiple lines: <pre>{@code
1399+ * [
1400+ * 1,
1401+ * "value 2",
1402+ * 3
1403+ * ]
1404+ * }</pre>
1405+ * <p><b>
13771406 * Warning: This method assumes that the data structure is acyclical.
1407+ * </b>
13781408 *
13791409 * @param writer
13801410 * Writes the serialized JSON
0 commit comments