當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonWriter.writeArray方法代碼示例

本文整理匯總了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();
}
 
開發者ID:samolisov,項目名稱:bluemix-liberty-microprofile-demo,代碼行數:15,代碼來源:ReservationSetProvider.java

示例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();
}
 
開發者ID:eclipse,項目名稱:microprofile-conference,代碼行數:14,代碼來源:SessionRatingListProvider.java

示例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();
}
 
開發者ID:eclipse,項目名稱:microprofile-conference,代碼行數:14,代碼來源:AttendeeListProvider.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:7,代碼來源:ConfigDocumentationBean.java

示例5: doWrite

import javax.json.JsonWriter; //導入方法依賴的package包/類
@Override
protected void doWrite(final JsonWriter writer, final JsonArray array) {
    writer.writeArray(array);
}
 
開發者ID:apache,項目名稱:johnzon,代碼行數:5,代碼來源:JsrArrayEncoder.java


注:本文中的javax.json.JsonWriter.writeArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。