本文整理匯總了Java中javax.json.JsonWriter.writeArray方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.writeArray方法的具體用法?Java JsonWriter.writeArray怎麽用?Java JsonWriter.writeArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.writeArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeTo
import javax.json.JsonWriter; //導入方法依賴的package包/類
@Override
public void writeTo(Set<Reservation> set, Class<?> clazz, Type type, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream os)
throws IOException, WebApplicationException {
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
Iterator<Reservation> reservations = set.iterator();
while (reservations.hasNext()) {
Reservation reservation = reservations.next();
arrayBuilder.add(reservationJsonAdapter.toJson(reservation));
}
JsonWriter jsonWriter = Json.createWriter(os);
jsonWriter.writeArray(arrayBuilder.build());
jsonWriter.close();
}
示例2: writeTo
import javax.json.JsonWriter; //導入方法依賴的package包/類
@Override
public void writeTo(List<SessionRating> sessionRatings, Class<?> clazz, Type type, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> map, OutputStream os) throws IOException, WebApplicationException {
JsonWriter writer = Json.createWriter(new TeeOutputStream(os, System.out));
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
for (SessionRating sessionRating : sessionRatings) {
JsonObject sessionRatingJson = SessionRating.toJSON(sessionRating);
arrayBuilder.add(sessionRatingJson);
}
writer.writeArray(arrayBuilder.build());
writer.close();
}
示例3: writeTo
import javax.json.JsonWriter; //導入方法依賴的package包/類
@Override
public void writeTo(List<Attendee> Attendees, Class<?> clazz, Type type, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> map, OutputStream os) throws IOException, WebApplicationException {
JsonWriter writer = Json.createWriter(new TeeOutputStream(os, System.out));
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
for (Attendee attendee : Attendees) {
JsonObject attendeeJson = Attendee.toJSON(attendee);
arrayBuilder.add(attendeeJson);
}
writer.writeArray(arrayBuilder.build());
writer.close();
}
示例4: formatJson
import javax.json.JsonWriter; //導入方法依賴的package包/類
private String formatJson(JsonArray data) {
StringWriter writer = new StringWriter();
JsonWriter gen = writerFactory.createWriter(writer);
gen.writeArray(data);
return writer.toString();
}
示例5: doWrite
import javax.json.JsonWriter; //導入方法依賴的package包/類
@Override
protected void doWrite(final JsonWriter writer, final JsonArray array) {
writer.writeArray(array);
}