MCPcopy Index your code
hub / github.com/processing/processing / valueToString

Method valueToString

core/src/processing/data/JSONObject.java:1665–1698  ·  view source on GitHub ↗

Make a JSON text of an Object value. If the object has an value.toJSONString() method, then that method will be used to produce the JSON text. The method is required to produce a strictly conforming text. If the object does not contain a toJSONString method (which is the most common case), then a te

(Object value)

Source from the content-addressed store, hash-verified

1663 * @throws RuntimeException If the value is or contains an invalid number.
1664 */
1665 static protected String valueToString(Object value) {
1666 if (value == null || value.equals(null)) {
1667 return "null";
1668 }
1669// if (value instanceof JSONString) {
1670// Object object;
1671// try {
1672// object = ((JSONString)value).toJSONString();
1673// } catch (Exception e) {
1674// throw new RuntimeException(e);
1675// }
1676// if (object instanceof String) {
1677// return (String)object;
1678// }
1679// throw new RuntimeException("Bad value from toJSONString: " + object);
1680// }
1681 if (value instanceof Number) {
1682 return numberToString((Number) value);
1683 }
1684 if (value instanceof Boolean || value instanceof JSONObject ||
1685 value instanceof JSONArray) {
1686 return value.toString();
1687 }
1688 if (value instanceof Map) {
1689 return new JSONObject(value).toString();
1690 }
1691 if (value instanceof Collection) {
1692 return new JSONArray(value).toString();
1693 }
1694 if (value.getClass().isArray()) {
1695 return new JSONArray(value).toString();
1696 }
1697 return quote(value.toString());
1698 }
1699
1700 /**
1701 * Wrap an object, if necessary. If the object is null, return the NULL

Callers 1

joinMethod · 0.95

Calls 4

numberToStringMethod · 0.95
quoteMethod · 0.95
equalsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected