Skip to content

Commit 826ceef

Browse files
committed
Minor tweaks.
1 parent c91c37a commit 826ceef

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

JSONArray.java

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public String join(String separator) throws JSONException {
434434
if (i > 0) {
435435
sb.append(separator);
436436
}
437-
sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
437+
JSONObject.writeValue(sb, this.myArrayList.get(i));
438438
}
439439
return sb.toString();
440440
}

JSONObject.java

100644100755
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,11 +1672,7 @@ public String toString(int indentFactor) throws JSONException {
16721672
* If the value is or contains an invalid number.
16731673
*/
16741674
public static String valueToString(Object value) throws JSONException {
1675-
try {
1676-
return writeValue(new StringBuilder(), value, 0, 0).toString();
1677-
} catch (IOException e) {
1678-
throw new JSONException(e);
1679-
}
1675+
return writeValue(new StringBuilder(), value).toString();
16801676
}
16811677

16821678
/**
@@ -1745,6 +1741,15 @@ public <T extends Appendable> T write(T writer) throws JSONException {
17451741
return this.write(writer, 0, 0);
17461742
}
17471743

1744+
static <T extends Appendable> T writeValue(T writer, Object value)
1745+
throws JSONException {
1746+
try {
1747+
return writeValue(writer, value, 0 ,0);
1748+
} catch (IOException e) {
1749+
throw new JSONException(e);
1750+
}
1751+
}
1752+
17481753
static final <T extends Appendable> T writeValue(T writer, Object value,
17491754
int indentFactor, int indent) throws JSONException, IOException {
17501755
if (value == null || value.equals(null)) {

JSONWriter.java

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public JSONWriter value(boolean b) throws JSONException {
299299
* @throws JSONException If the number is not finite.
300300
*/
301301
public JSONWriter value(double d) throws JSONException {
302-
return this.value(new Double(d));
302+
return this.append(JSONObject.numberToString(Double.valueOf(d)));
303303
}
304304

305305
/**

0 commit comments

Comments
 (0)