43444546474849505152
/** * @return "true" or "false" for a boolean value */ public static String toJson(Boolean bool) { CharBuf buffer = CharBuf.create(4); writeObject(bool, buffer); // checking null inside return buffer.toString(); }
6061626364656667686970
public static String toJson(Number n) { if (n == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(3); Class<?> numberClass = n.getClass(); writeNumber(numberClass, n, buffer); return buffer.toString(); }
71727374757677787980
/** * @return a JSON string representation of the character */ public static String toJson(Character c) { CharBuf buffer = CharBuf.create(3); writeObject(c, buffer); // checking null inside return buffer.toString(); }
85868788899091929394
public static String toJson(String s) { if (s == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(s.length() + 2); writeCharSequence(s, buffer); return buffer.toString(); }
102103104105106107108109110111
public static String toJson(Date date) { if (date == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(26); writeDate(date, buffer); return buffer.toString(); }
119120121122123124125126127128
public static String toJson(Calendar cal) { if (cal == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(26); writeDate(cal.getTime(), buffer); return buffer.toString(); }
129130131132133134135136137138
/** * @return the string representation of an uuid */ public static String toJson(UUID uuid) { CharBuf buffer = CharBuf.create(64); writeObject(uuid, buffer); // checking null inside return buffer.toString(); }
139140141142143144145146147148
/** * @return the string representation of the URL */ public static String toJson(URL url) { CharBuf buffer = CharBuf.create(64); writeObject(url, buffer); // checking null inside return buffer.toString(); }
153154155156157158159160161162
public static String toJson(Closure closure) { if (closure == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(255); writeMap(JsonDelegate.cloneDelegateAndGetContent(closure), buffer); return buffer.toString(); }
167168169170171172173174175176
public static String toJson(Expando expando) { if (expando == null) { return NULL_VALUE; } CharBuf buffer = CharBuf.create(255); writeMap(expando.getProperties(), buffer); return buffer.toString(); }