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


Java JsonGenerator.setPrettyPrinter方法代码示例

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


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

示例1: exportTo

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
/**
 * Exports data to a {@link Writer}.
 *
 * @param writer the writer
 * @throws NitriteIOException if there is any error while writing the data.
 */
public void exportTo(Writer writer) {
    JsonGenerator generator;
    try {
        generator = jsonFactory.createGenerator(writer);
        generator.setPrettyPrinter(new DefaultPrettyPrinter());
    } catch (IOException ioe) {
        throw new NitriteIOException(EXPORT_WRITER_ERROR, ioe);
    }

    NitriteJsonExporter jsonExporter = new NitriteJsonExporter(db);
    jsonExporter.setGenerator(generator);
    jsonExporter.setOptions(options);
    try {
        jsonExporter.exportData();
    } catch (IOException | ClassNotFoundException e) {
        throw new NitriteIOException(EXPORT_WRITE_ERROR, e);
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:25,代码来源:Exporter.java

示例2: enableDisableJSONGeneratorFeature

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void enableDisableJSONGeneratorFeature(JsonGenerator jg) {
  jg.enable(Feature.ESCAPE_NON_ASCII);
  jg.disable(Feature.AUTO_CLOSE_TARGET);
  jg.setPrettyPrinter(new DefaultPrettyPrinter());
  if (PDXTOJJSON_UNQUOTEFIELDNAMES)
    jg.disable(Feature.QUOTE_FIELD_NAMES);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:PdxToJSON.java

示例3: startPartition

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void startPartition(WritePartition partition) throws Exception {
  // close previous partition if open.
  if(this.partition != null){
    close();
  }
  this.partition = partition;

  try {
    this.fileName = fs.canonicalizePath(partition.qualified(location, prefix + "_0." + extension));
    stream = fs.create(fileName);
    JsonGenerator generator = factory.createGenerator(stream).useDefaultPrettyPrinter();
    if (uglify) {
      generator = generator.setPrettyPrinter(new MinimalPrettyPrinter(LINE_FEED));
    }
    if(useExtendedOutput){
      gen = new ExtendedJsonOutput(generator);
    }else{
      gen = new BasicJsonOutput(generator);
    }
    logger.debug("Created file: {}", fileName);
  } catch (IOException ex) {
    throw UserException.dataWriteError(ex)
      .message("Failure writing JSON file %s.", fileName)
      .build(logger);
  }

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:29,代码来源:JsonRecordWriter.java

示例4: createGenerator

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException {
  JsonGenerator generator = super.createGenerator(out, enc);
  generator.setPrettyPrinter(pp);
  return generator;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:7,代码来源:JSONUtil.java

示例5: write

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
long write(File file) throws IOException {

        long timestamp = System.currentTimeMillis();

        if (file.exists()) {
            file.delete();
        }

        JsonFactory f = new JsonFactory();
        JsonGenerator g = f.createGenerator(file, JsonEncoding.UTF8);
        g.setPrettyPrinter(new DefaultPrettyPrinter() );

        g.writeStartObject();

        g.writeFieldName("database");
        g.writeStartObject();
        // Nome database
        g.writeStringField("name",databaseName);

        // Tabelle
        g.writeFieldName("tables");
        g.writeStartArray();

        for (Map.Entry<String, Integer> entry : tablesToWrite.entrySet()) {

            g.writeStartObject();

            g.writeStringField("name",entry.getKey());

            g.writeArrayFieldStart("records");

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            for (int i = 0; i < entry.getValue();++i) {

                g.writeStartObject();

                g.writeNumberField("cId", new Date().getTime());

                String name = entry.getKey();
                name = name + " " + i;

                g.writeStringField("name", name);

                g.writeStringField("dateCreated", simpleDateFormat.format(new Date()));
                g.writeStringField("dateUpdated", simpleDateFormat.format(new Date()));


                g.writeEndObject();
            }

            g.writeEndArray();

            g.writeEndObject();
        }

        g.writeEndArray();
        g.writeEndObject();

        g.writeEndObject();
        g.close();

        return System.currentTimeMillis() - timestamp;
    }
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:64,代码来源:JSonDatabaseWriter.java


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