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


Java JsonGenerator.setPrettyPrinter方法代碼示例

本文整理匯總了Java中org.codehaus.jackson.JsonGenerator.setPrettyPrinter方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.setPrettyPrinter方法的具體用法?Java JsonGenerator.setPrettyPrinter怎麽用?Java JsonGenerator.setPrettyPrinter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.jackson.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.setPrettyPrinter方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AvroFileInputStream

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
public AvroFileInputStream(FileStatus status) throws IOException {
  pos = 0;
  buffer = new byte[0];
  GenericDatumReader<Object> reader = new GenericDatumReader<Object>();
  FileContext fc = FileContext.getFileContext(new Configuration());
  fileReader =
    DataFileReader.openReader(new AvroFSInput(fc, status.getPath()),reader);
  Schema schema = fileReader.getSchema();
  writer = new GenericDatumWriter<Object>(schema);
  output = new ByteArrayOutputStream();
  JsonGenerator generator =
    new JsonFactory().createJsonGenerator(output, JsonEncoding.UTF8);
  MinimalPrettyPrinter prettyPrinter = new MinimalPrettyPrinter();
  prettyPrinter.setRootValueSeparator(System.getProperty("line.separator"));
  generator.setPrettyPrinter(prettyPrinter);
  encoder = EncoderFactory.get().jsonEncoder(schema, generator);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:18,代碼來源:Display.java

示例2: createJsonGenerator

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
/**
 * This is a helper method which creates a JsonGenerator instance, for writing
 * the state of the ClusterManager to the state file. The JsonGenerator
 * instance writes to a compressed file if we have the compression flag
 * turned on.
 *
 * @param conf The CoronaConf instance to be used
 * @return The JsonGenerator instance to be used
 * @throws IOException
 */
public static JsonGenerator createJsonGenerator(CoronaConf conf)
  throws IOException {
  OutputStream outputStream = new FileOutputStream(conf.getCMStateFile());
  if (conf.getCMCompressStateFlag()) {
    outputStream = new GZIPOutputStream(outputStream);
  }
  ObjectMapper mapper = new ObjectMapper();
  JsonGenerator jsonGenerator =
    new JsonFactory().createJsonGenerator(outputStream, JsonEncoding.UTF8);
  jsonGenerator.setCodec(mapper);
  if (!conf.getCMCompressStateFlag()) {
    jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter());
  }
  return jsonGenerator;
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:26,代碼來源:CoronaSerializer.java

示例3: AvroFileInputStream

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
public AvroFileInputStream(FileStatus status) throws IOException {
  pos = 0;
  buffer = new byte[0];
  GenericDatumReader<Object> reader = new GenericDatumReader<Object>();
  fileReader =
    DataFileReader.openReader(new File(status.getPath().toUri()), reader);
  Schema schema = fileReader.getSchema();
  writer = new GenericDatumWriter<Object>(schema);
  output = new ByteArrayOutputStream();
  JsonGenerator generator =
    new JsonFactory().createJsonGenerator(output, JsonEncoding.UTF8);
  MinimalPrettyPrinter prettyPrinter = new MinimalPrettyPrinter();
  prettyPrinter.setRootValueSeparator(System.getProperty("line.separator"));
  generator.setPrettyPrinter(prettyPrinter);
  encoder = EncoderFactory.get().jsonEncoder(schema, generator);
}
 
開發者ID:ict-carch,項目名稱:hadoop-plus,代碼行數:17,代碼來源:Display.java

示例4: getJsonGenerator

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
private static JsonGenerator getJsonGenerator(OutputStream out) throws IOException {
  if (null == out) {
    throw new NullPointerException("OutputStream cannot be null");
  }
  JsonGenerator g = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);
  MinimalPrettyPrinter pp = new MinimalPrettyPrinter();
  pp.setRootValueSeparator(System.getProperty("line.separator"));
  g.setPrettyPrinter(pp);
  return g;
}
 
開發者ID:HotelsDotCom,項目名稱:jasvorno,代碼行數:11,代碼來源:JasvornoEncoder.java

示例5: writeEntities

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
/**
 * Write timeline entities to a file system
 * @param entities
 * @param logPath
 * @param fs
 * @throws IOException
 */
static void writeEntities(TimelineEntities entities, Path logPath,
    FileSystem fs) throws IOException {
  FSDataOutputStream outStream = createLogFile(logPath, fs);
  JsonGenerator jsonGenerator
      = (new JsonFactory()).createJsonGenerator(outStream);
  jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
  ObjectMapper objMapper = createObjectMapper();
  for (TimelineEntity entity : entities.getEntities()) {
    objMapper.writeValue(jsonGenerator, entity);
  }
  outStream.close();
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:20,代碼來源:PluginStoreTestUtils.java

示例6: writeDomainLeaveOpen

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
private void writeDomainLeaveOpen(TimelineDomain domain, Path logPath)
    throws IOException {
  if (outStreamDomain == null) {
    outStreamDomain = PluginStoreTestUtils.createLogFile(logPath, fs);
  }
  // Write domain uses its own json generator to isolate from entity writers
  JsonGenerator jsonGeneratorLocal
      = (new JsonFactory()).createJsonGenerator(outStreamDomain);
  jsonGeneratorLocal.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
  objMapper.writeValue(jsonGeneratorLocal, domain);
  outStreamDomain.hflush();
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:13,代碼來源:TestLogInfo.java

示例7: getJsonGenerator

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
private static JsonGenerator getJsonGenerator(OutputStream out)
    throws IOException {
  if (null == out)
    throw new NullPointerException("OutputStream cannot be null"); 
  JsonGenerator g
    = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);
  MinimalPrettyPrinter pp = new MinimalPrettyPrinter();
  pp.setRootValueSeparator("\n");
  g.setPrettyPrinter(pp);
  return g;
}
 
開發者ID:openaire,項目名稱:iis,代碼行數:12,代碼來源:HackedJsonEncoder.java

示例8: JsonTransformer

import org.codehaus.jackson.JsonGenerator; //導入方法依賴的package包/類
private JsonTransformer(JsonGenerator json, ISSTableScanner currentScanner, boolean rawTime, CFMetaData metadata)
{
    this.json = json;
    this.metadata = metadata;
    this.currentScanner = currentScanner;
    this.rawTime = rawTime;

    DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
    prettyPrinter.indentObjectsWith(objectIndenter);
    prettyPrinter.indentArraysWith(arrayIndenter);
    json.setPrettyPrinter(prettyPrinter);
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:13,代碼來源:JsonTransformer.java


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