當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。