javax.json.Json.createWriterFactory()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中javax.json.Json.createWriterFactory()方法的一些代码示例,展示了Json.createWriterFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createWriterFactory()方法的具体详情如下:
包路径:javax.json.Json
类名称:Json
方法名:createWriterFactory

Json.createWriterFactory介绍

[英]Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.
[中]创建用于创建JsonWriter对象的编写器工厂。工厂使用特定于提供程序的配置属性的指定映射进行配置。提供程序实现应忽略映射中指定的任何不受支持的配置属性。

代码示例

代码示例来源:origin: oracle/helidon

private static JsonWriterFactory writerFactory(Map<String, ?> jsonPConfig) {
  return Json.createWriterFactory(jsonPConfig);
}

代码示例来源:origin: io.helidon.media.jsonp/helidon-media-jsonp-common

private static JsonWriterFactory writerFactory(Map<String, ?> jsonPConfig) {
  return Json.createWriterFactory(jsonPConfig);
}

代码示例来源:origin: org.apache.johnzon/johnzon-websocket

private static JsonWriterFactory newWriterFactory() {
    return Json.createWriterFactory(Collections.<String, Object>emptyMap());
  }
}

代码示例来源:origin: apache/johnzon

private static JsonWriterFactory newWriterFactory() {
    return Json.createWriterFactory(Collections.<String, Object>emptyMap());
  }
}

代码示例来源:origin: org.apache.johnzon/johnzon-jaxrs

public JsrMessageBodyWriter() {
  this(Json.createWriterFactory(Collections.<String, Object>emptyMap()), false);
}

代码示例来源:origin: net.iot-solutions.graphdb/jcypher

private static JsonWriterFactory createPrettyWriterFactory() {
  HashMap<String, Object> prettyConfigMap = new HashMap<String, Object>();
  prettyConfigMap.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
  JsonWriterFactory prettyWriterFactory = Json.createWriterFactory(prettyConfigMap);
  return prettyWriterFactory;
}

代码示例来源:origin: Wolfgang-Schuetzelhofer/jcypher

private static JsonWriterFactory createPrettyWriterFactory() {
  HashMap<String, Object> prettyConfigMap = new HashMap<String, Object>();
  prettyConfigMap.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
  JsonWriterFactory prettyWriterFactory = Json.createWriterFactory(prettyConfigMap);
  return prettyWriterFactory;
}

代码示例来源:origin: org.apache.tamaya.ext/tamaya-model

/**
 * Creates an mbean bound to the given configuration. This is useful, when multiple mbeans for each
 * context should be used, e.g. one mbean per ear, app deployment.
 * @param config the configuration to be used.
 */
public ConfigDocumentationBean(Configuration config){
  this.config = config;
  Map<String, Object> writerProperties = new HashMap<>(1);
  writerProperties.put(JsonGenerator.PRETTY_PRINTING, true);
  writerFactory = Json.createWriterFactory(writerProperties);
}

代码示例来源:origin: eclipse-ee4j/jsonp

@PostConstruct
private void init() {
  wf = Json.createWriterFactory(new HashMap<>());
}

代码示例来源:origin: org.glassfish/jsonp-jaxrs

@PostConstruct
private void init() {
  Map<String, Object> props = new HashMap<>();
  if (config != null && config.getProperties().containsKey(JsonGenerator.PRETTY_PRINTING)) {
    props.put(JsonGenerator.PRETTY_PRINTING, true);
  }
  wf = Json.createWriterFactory(props);
}

代码示例来源:origin: eclipse-ee4j/jsonp

@PostConstruct
private void init() {
  Map<String, Object> props = new HashMap<>();
  if (config != null && config.getProperties().containsKey(JsonGenerator.PRETTY_PRINTING)) {
    props.put(JsonGenerator.PRETTY_PRINTING, true);
  }
  wf = Json.createWriterFactory(props);
}

代码示例来源:origin: USPTO/PatentPublicData

public String getPrettyPrint(JsonObject jsonObject) throws IOException {
  Map<String, Boolean> config = new HashMap<String, Boolean>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonWriterFactory writerFactory = Json.createWriterFactory(config);
  String output = null;
  try (StringWriter sw = new StringWriter(); JsonWriter jsonWriter = writerFactory.createWriter(sw)) {
    jsonWriter.writeObject(jsonObject);
    output = sw.toString();
  }
  return output;
}

代码示例来源:origin: IQSS/dataverse

public static String prettyPrint(JsonArray jsonArray) {
  Map<String, Boolean> config = new HashMap<>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonWriterFactory jsonWriterFactory = Json.createWriterFactory(config);
  StringWriter stringWriter = new StringWriter();
  try (JsonWriter jsonWriter = jsonWriterFactory.createWriter(stringWriter)) {
    jsonWriter.writeArray(jsonArray);
  }
  return stringWriter.toString();
}

代码示例来源:origin: IQSS/dataverse

public static String prettyPrint(javax.json.JsonObject jsonObject) {
  Map<String, Boolean> config = new HashMap<>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonWriterFactory jsonWriterFactory = Json.createWriterFactory(config);
  StringWriter stringWriter = new StringWriter();
  try (JsonWriter jsonWriter = jsonWriterFactory.createWriter(stringWriter)) {
    jsonWriter.writeObject(jsonObject);
  }
  return stringWriter.toString();
}

代码示例来源:origin: USPTO/PatentPublicData

public String getPrettyPrint(JsonObject jsonObject) throws IOException {
  Map<String, Boolean> config = new HashMap<String, Boolean>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonWriterFactory writerFactory = Json.createWriterFactory(config);
  String output = null;
  try (StringWriter sw = new StringWriter(); JsonWriter jsonWriter = writerFactory.createWriter(sw)) {
    jsonWriter.writeObject(jsonObject);
    output = sw.toString();
  }
  return output;
}

代码示例来源:origin: USPTO/PatentPublicData

public String getPrettyPrint(JsonObject jsonObject) throws IOException {
  Map<String, Boolean> config = new HashMap<String, Boolean>();
  config.put(JsonGenerator.PRETTY_PRINTING, true);
  JsonWriterFactory writerFactory = Json.createWriterFactory(config);
  String output = null;
  try (StringWriter sw = new StringWriter(); JsonWriter jsonWriter = writerFactory.createWriter(sw)) {
    jsonWriter.writeObject(jsonObject);
    output = sw.toString();
  }
  return output;
}

代码示例来源:origin: sdaschner/jaxrs-analyzer

private static byte[] serialize(final JsonObject jsonObject) {
  try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
    final Map<String, ?> config = singletonMap(JsonGenerator.PRETTY_PRINTING, true);
    final JsonWriter jsonWriter = Json.createWriterFactory(config).createWriter(output);
    jsonWriter.write(jsonObject);
    jsonWriter.close();
    return output.toByteArray();
  } catch (IOException e) {
    throw new RuntimeException("Could not write Swagger output", e);
  }
}

代码示例来源:origin: com.sebastian-daschner/jaxrs-analyzer

private static byte[] serialize(final JsonObject jsonObject) {
  try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
    final Map<String, ?> config = singletonMap(JsonGenerator.PRETTY_PRINTING, true);
    final JsonWriter jsonWriter = Json.createWriterFactory(config).createWriter(output);
    jsonWriter.write(jsonObject);
    jsonWriter.close();
    return output.toByteArray();
  } catch (IOException e) {
    throw new RuntimeException("Could not write Swagger output", e);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-extras

/**
 * Creates a new instance using the provided configuration.
 *
 * @param config A map of provider-specific configuration properties. May be empty or {@code
 *     null}.
 */
public Jsr353JsonCodec(Map<String, ?> config) {
 super(DataType.varchar(), JsonStructure.class);
 readerFactory = Json.createReaderFactory(config);
 writerFactory = Json.createWriterFactory(config);
}

代码示例来源:origin: io.smallrye/smallrye-health

public void reportHealth(OutputStream out, SmallRyeHealth health) {
  JsonWriterFactory factory = Json.createWriterFactory(JSON_CONFIG);
  JsonWriter writer = factory.createWriter(out);
  writer.writeObject(health.getPayload());
  writer.close();
}

相关文章