当前位置: 首页>>代码示例>>Java>>正文


Java Json.createWriter方法代码示例

本文整理汇总了Java中javax.json.Json.createWriter方法的典型用法代码示例。如果您正苦于以下问题:Java Json.createWriter方法的具体用法?Java Json.createWriter怎么用?Java Json.createWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.json.Json的用法示例。


在下文中一共展示了Json.createWriter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unwrapJsonObjects

import javax.json.Json; //导入方法依赖的package包/类
public static Object unwrapJsonObjects(Object entity) {
    if (entity instanceof JsonObjectBuilder) {
        JsonObjectBuilder jsonObjectBuilder = (JsonObjectBuilder) entity;
        entity = jsonObjectBuilder.build();
    }
    if (entity instanceof JsonStructure) {
        StringWriter buffer = new StringWriter();
        JsonWriter writer = Json.createWriter(buffer);
        writer.write((JsonStructure) entity);
        writer.close();
        return buffer.toString();
    }
    return entity;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:15,代码来源:JsonOperations.java

示例2: writeJsonStructure

import javax.json.Json; //导入方法依赖的package包/类
public String writeJsonStructure() {

        StringWriter stringWriter = new StringWriter();
        JsonWriter jsonWriter = Json.createWriter(stringWriter);
        jsonWriter.writeObject(new ObjectExample3().buildJsonDocument());
        jsonWriter.close();

        return stringWriter.toString();
    }
 
开发者ID:readlearncode,项目名称:JSON-Processing-with-Java-EE,代码行数:10,代码来源:ObjectExample6.java

示例3: toJson

import javax.json.Json; //导入方法依赖的package包/类
@Override
public void toJson(OutputStream os, Reservation reservation) {
	Objects.requireNonNull(reservation, RESERVATION_ISNT_ALLOWED_TO_BE_NULL);
	JsonWriter jsonWriter = Json.createWriter(os);
       jsonWriter.writeObject(toJson(reservation));
       jsonWriter.close();
}
 
开发者ID:samolisov,项目名称:bluemix-liberty-microprofile-demo,代码行数:8,代码来源:ReservationJsonAdapter.java

示例4: writeTo

import javax.json.Json; //导入方法依赖的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

示例5: main

import javax.json.Json; //导入方法依赖的package包/类
public static void main(String ...arg) throws IOException {

        File file = new File("json-output.json");

        try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {

            if (!file.exists()) {
                file.createNewFile();
            }

            JsonWriter jsonWriter = Json.createWriter(fileOutputStream);
            jsonWriter.writeObject(new ObjectExample3().buildJsonDocument());

            jsonWriter.close();

            // Flush and close file output streams
            fileOutputStream.flush();
            fileOutputStream.close();
        }

    }
 
开发者ID:readlearncode,项目名称:JSON-Processing-with-Java-EE,代码行数:22,代码来源:ObjectExample7.java

示例6: writeTo

import javax.json.Json; //导入方法依赖的package包/类
public static void writeTo(DecisionDao t,OutputStream out) throws IOException {
    try (JsonWriter writer = Json.createWriter(out)) {
        writer.write(getJson(t));
    }
}
 
开发者ID:avraampiperidis,项目名称:DiavgeiaUtils,代码行数:6,代码来源:DecisionDaoProvider.java


注:本文中的javax.json.Json.createWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。