/** * Returns the JSON representation of the provided {@code value} * * @param value the value to serialize to JSON * @return the serialized value */ public static String toJson(Object value) { if (value instanceof String) { return '"' + (String) value + '"'; } else if (value instanceof Collection) { return "[" + toJsonCollection((Collection) value) + "]"; } else { throw new IllegalArgumentException("Unable to convert " + value + " to JSON"); } }