}
}
+ /**
+ * Write a list of values in an array, for example:
+ * <pre>
+ * writer.beginArray().values(myValues).endArray();
+ * </pre>
+ *
+ * @throws org.sonar.api.utils.text.WriterException on any failure
+ */
+ public JsonWriter values(Iterable<String> values) {
+ for (String value : values) {
+ value(value);
+ }
+ return this;
+ }
+
/**
* @throws org.sonar.api.utils.text.WriterException on any failure
*/
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Arrays;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
expect("{\"issues\":[{\"key\":\"ABC\"},{\"key\":\"DEF\"}]}");
}
+ @Test
+ public void array_values() throws Exception {
+ writer.beginArray().values(Arrays.asList("foo", "bar", "baz")).endArray().close();
+ expect("[\"foo\",\"bar\",\"baz\"]");
+ }
+
@Test
public void type_of_values() throws Exception {
Date date = DateUtils.parseDateTime("2010-05-18T15:50:45+0100");