MCPcopy Index your code
hub / github.com/jOOQ/jOOQ / toJSONString

Method toJSONString

jOOQ/src/main/java/org/jooq/tools/json/JSONArray.java:97–121  ·  view source on GitHub ↗

Convert a list to JSON text. The result is a JSON array. @see JSONValue#toJSONString(Object) @return JSON text, or "null" if list is null.

(List<?> list)

Source from the content-addressed store, hash-verified

95 * @return JSON text, or "null" if list is null.
96 */
97 public static String toJSONString(List<?> list) {
98 if (list == null)
99 return "null";
100
101 boolean first = true;
102 StringBuffer sb = new StringBuffer();
103 Iterator<?> iter = list.iterator();
104
105 sb.append('[');
106 while (iter.hasNext()) {
107 if (first)
108 first = false;
109 else
110 sb.append(',');
111
112 Object value = iter.next();
113 if (value == null) {
114 sb.append("null");
115 continue;
116 }
117 sb.append(JSONValue.toJSONString(value));
118 }
119 sb.append(']');
120 return sb.toString();
121 }
122
123 @Override
124 public String toString() {

Callers 1

toStringMethod · 0.95

Calls 6

toJSONStringMethod · 0.95
iteratorMethod · 0.65
appendMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected