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


Java JsonGenerator.useDefaultPrettyPrinter方法代碼示例

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


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

示例1: toString

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
public String toString(boolean pretty)
{
   try
   {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JsonGenerator json = new JsonFactory().createGenerator(baos);
      if (pretty)
         json.useDefaultPrettyPrinter();
      write(json, new HashSet());
      json.flush();
      baos.flush();

      return new String(baos.toByteArray());
   }
   catch (Exception ex)
   {
      throw new RuntimeException(ex);
   }
}
 
開發者ID:wellsb1,項目名稱:fort_w,代碼行數:20,代碼來源:JSObject.java

示例2: modify

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public ObjectWriter modify(EndpointConfigBase<?> endpointConfigBase, MultivaluedMap<String, Object> multivaluedMap,
                           Object o, ObjectWriter objectWriter, JsonGenerator jsonGenerator) throws IOException {

    jsonGenerator.useDefaultPrettyPrinter();
    return objectWriter;
}
 
開發者ID:stevespringett,項目名稱:Alpine,代碼行數:8,代碼來源:PrettyPrintFilter.java

示例3: decorate

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public JsonGenerator decorate(JsonGenerator generator) {
  if (Boolean.valueOf(System.getenv("DENSE_LOGS"))) {
    return generator;
  }
  return generator.useDefaultPrettyPrinter();
}
 
開發者ID:codahale,項目名稱:grpc-proxy,代碼行數:8,代碼來源:PrettyPrintingDecorator.java

示例4: writeInternal

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
protected void writeInternal(Object object, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	// The following has been deprecated as late as Jackson 2.2 (April 2013);
	// preserved for the time being, for Jackson 2.0/2.1 compatibility.
	@SuppressWarnings("deprecation")
	JsonGenerator jsonGenerator =
			this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);

	// A workaround for JsonGenerators not applying serialization features
	// https://github.com/FasterXML/jackson-databind/issues/12
	if (this.objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT)) {
		jsonGenerator.useDefaultPrettyPrinter();
	}

	try {
		if (this.jsonPrefix != null) {
			jsonGenerator.writeRaw(this.jsonPrefix);
		}
		this.objectMapper.writeValue(jsonGenerator, object);
	}
	catch (JsonProcessingException ex) {
		throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:MappingJackson2HttpMessageConverter.java

示例5: JsonWriter

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
public JsonWriter(OutputStream out, boolean pretty, boolean useExtendedOutput) throws IOException{
  JsonGenerator writer = factory.createJsonGenerator(out);
  if(pretty){
    writer = writer.useDefaultPrettyPrinter();
  }
  if(useExtendedOutput){
    gen = new ExtendedJsonOutput(writer);
  }else{
    gen = new BasicJsonOutput(writer);
  }

}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:13,代碼來源:JsonWriter.java

示例6: decorate

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public JsonGenerator decorate(JsonGenerator generator) {
    if (prettyPrintingEnabled()) {
        generator.useDefaultPrettyPrinter();
    }
    return generator;
}
 
開發者ID:hmcts,項目名稱:java-logging,代碼行數:8,代碼來源:PrettyPrintingDecorator.java

示例7: modify

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public ObjectWriter modify(EndpointConfigBase<?> endpoint, MultivaluedMap<String, Object> responseHeaders,
    Object valueToWrite, ObjectWriter w, JsonGenerator g) throws IOException {
  ObjectWriter writer = w;
  if (previous != null) {
    writer = previous.modify(endpoint, responseHeaders, valueToWrite, w, g);
  }
  g.useDefaultPrettyPrinter();
  return writer;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:11,代碼來源:JSONPrettyPrintFilter.java

示例8: decorate

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
@Override
public JsonGenerator decorate(JsonGenerator generator) {
    return generator.useDefaultPrettyPrinter();
}
 
開發者ID:skjolber,項目名稱:json-log-domain,代碼行數:5,代碼來源:PrettyPrintingDecorator.java

示例9: createPrettyGenerator

import com.fasterxml.jackson.core.JsonGenerator; //導入方法依賴的package包/類
public static JsonGenerator createPrettyGenerator(Writer writer) throws IOException {
    JsonGenerator generator = prettyFactory.createGenerator(writer);
    generator.useDefaultPrettyPrinter();
    return generator;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:6,代碼來源:Jackson.java


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