Encode a list into JSON text and write it to out. @see JSONValue#writeJSONString(Object, Writer)
(List<?> list, Writer out)
| 62 | * @see JSONValue#writeJSONString(Object, Writer) |
| 63 | */ |
| 64 | public static void writeJSONString(List<?> list, Writer out) throws IOException { |
| 65 | if (list == null) { |
| 66 | out.write("null"); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | boolean first = true; |
| 71 | Iterator<?> iter = list.iterator(); |
| 72 | |
| 73 | out.write('['); |
| 74 | while (iter.hasNext()) { |
| 75 | if (first) |
| 76 | first = false; |
| 77 | else |
| 78 | out.write(','); |
| 79 | |
| 80 | Object value = iter.next(); |
| 81 | if (value == null) { |
| 82 | out.write("null"); |
| 83 | continue; |
| 84 | } |
| 85 | |
| 86 | JSONValue.writeJSONString(value, out); |
| 87 | } |
| 88 | out.write(']'); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Convert a list to JSON text. The result is a JSON array. |
no test coverage detected