Skip to content

Commit 88f65c5

Browse files
author
John J. Aylward
committed
Merge branch 'master' of github.com:stleary/JSON-java into NumberOutputFix
# Conflicts: # JSONObject.java
2 parents 2f2cd4d + ebe69df commit 88f65c5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

JSONObject.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,9 @@ public static String valueToString(Object value) throws JSONException {
17211721
if (value.getClass().isArray()) {
17221722
return new JSONArray(value).toString();
17231723
}
1724+
if(value instanceof Enum<?>){
1725+
return quote(((Enum<?>)value).name());
1726+
}
17241727
return quote(value.toString());
17251728
}
17261729

@@ -1748,7 +1751,7 @@ public static Object wrap(Object object) {
17481751
|| object instanceof Long || object instanceof Boolean
17491752
|| object instanceof Float || object instanceof Double
17501753
|| object instanceof String || object instanceof BigInteger
1751-
|| object instanceof BigDecimal) {
1754+
|| object instanceof BigDecimal || object instanceof Enum) {
17521755
return object;
17531756
}
17541757

@@ -1818,6 +1821,8 @@ static final Writer writeValue(Writer writer, Object value,
18181821
}
18191822
} else if (value instanceof Boolean) {
18201823
writer.write(value.toString());
1824+
} else if (value instanceof Enum<?>) {
1825+
writer.write(quote(((Enum<?>)value).name()));
18211826
} else if (value instanceof JSONObject) {
18221827
((JSONObject) value).write(writer, indentFactor, indent);
18231828
} else if (value instanceof JSONArray) {

0 commit comments

Comments
 (0)