1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00
This commit is contained in:
harkue 2019-11-12 16:27:24 +08:00
parent 4b49bc94ce
commit 4990c3a180
4 changed files with 29 additions and 30 deletions

View file

@ -1409,7 +1409,7 @@ public class JSONArray implements Iterable<Object> {
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {
try {
boolean commanate = false;
boolean hasComma = false;
int length = this.length();
writer.write('[');
@ -1421,23 +1421,23 @@ public class JSONArray implements Iterable<Object> {
throw new JSONException("Unable to write JSONArray value at index: 0", e);
}
} else if (length != 0) {
final int newindent = indent + indentFactor;
final int newIndent = indent + indentFactor;
for (int i = 0; i < length; i += 1) {
if (commanate) {
if (hasComma) {
writer.write(',');
}
if (indentFactor > 0) {
writer.write('\n');
}
JSONObject.indent(writer, newindent);
JSONObject.indent(writer, newIndent);
try {
JSONObject.writeValue(writer, this.myArrayList.get(i),
indentFactor, newindent);
indentFactor, newIndent);
} catch (Exception e) {
throw new JSONException("Unable to write JSONArray value at index: " + i, e);
}
commanate = true;
hasComma = true;
}
if (indentFactor > 0) {
writer.write('\n');