本文整理汇总了Java中org.codehaus.jackson.util.DefaultPrettyPrinter类的典型用法代码示例。如果您正苦于以下问题:Java DefaultPrettyPrinter类的具体用法?Java DefaultPrettyPrinter怎么用?Java DefaultPrettyPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultPrettyPrinter类属于org.codehaus.jackson.util包,在下文中一共展示了DefaultPrettyPrinter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BaseLensCommand
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
/**
* Instantiates a new base lens command.
*/
public BaseLensCommand() {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(Inclusion.NON_NULL);
mapper.setSerializationInclusion(Inclusion.NON_DEFAULT);
pp = new DefaultPrettyPrinter();
pp.indentObjectsWith(new Indenter() {
@Override
public void writeIndentation(JsonGenerator jg, int level) throws IOException {
jg.writeRaw("\n");
for (int i = 0; i < level; i++) {
jg.writeRaw(" ");
}
}
@Override
public boolean isInline() {
return false;
}
});
}
示例2: JsonTransformer
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的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);
}
示例3: init
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
private ByteArrayOutputStream init() throws IOException {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
m_generator = createJsonGenerator(bytesOut);
DefaultPrettyPrinter p = new DefaultPrettyPrinter();
p.indentArraysWith(new DefaultPrettyPrinter.Lf2SpacesIndenter());
m_generator.setPrettyPrinter(p);
return bytesOut;
}
示例4: createJsonGenerator
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
private JsonGenerator createJsonGenerator(ByteArrayOutputStream baos) throws IOException {
JsonGenerator generator = m_factory.createJsonGenerator(new OutputStreamWriter(baos,
Charset.forName("UTF-8").newEncoder()));
DefaultPrettyPrinter p = new DefaultPrettyPrinter();
p.indentArraysWith(new DefaultPrettyPrinter.Lf2SpacesIndenter());
generator.setPrettyPrinter(p);
return generator;
}
示例5: toJson
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public String toJson()
{
try
{
return new ObjectMapper().writer( new DefaultPrettyPrinter() ).writeValueAsString( this );
}
catch ( Exception e )
{
throw new RuntimeException( "Error serializing to JSON string", e );
}
}
示例6: DbValidationResult
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
DbValidationResult( Db db )
{
this.db = db;
this.missingHandlersForOperationTypes = new HashSet<>();
this.unableToExecuteOperations = new ArrayList<>();
this.incorrectResultsForOperations = new ArrayList<>();
this.successfullyExecutedOperationsPerOperationType = new HashMap<>();
this.totalOperationsPerOperationType = new HashMap<>();
this.objectMapper = new ObjectMapper();
this.defaultPrettyPrinter = new DefaultPrettyPrinter();
this.defaultPrettyPrinter.indentArraysWith( new DefaultPrettyPrinter.Lf2SpacesIndenter() );
}
示例7: toJson
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public String toJson()
{
try
{
return new ObjectMapper().writer( new DefaultPrettyPrinter() ).writeValueAsString( this );
}
catch ( Exception e )
{
System.out.println( ConcurrentErrorReporter.stackTraceToString( e ) );
throw new RuntimeException( "Unable to generate parameter values string", e );
}
}
示例8: JSONArrayMeasurementsExporter
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public JSONArrayMeasurementsExporter(OutputStream os) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
g = factory.createJsonGenerator(bw);
g.setPrettyPrinter(new DefaultPrettyPrinter());
g.writeStartArray();
}
示例9: JSONMeasurementsExporter
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public JSONMeasurementsExporter(OutputStream os) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
g = factory.createJsonGenerator(bw);
g.setPrettyPrinter(new DefaultPrettyPrinter());
}
示例10: _defaultPrettyPrinter
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
protected PrettyPrinter _defaultPrettyPrinter()
{
return new DefaultPrettyPrinter();
}
示例11: withDefaultPrettyPrinter
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public ObjectWriter withDefaultPrettyPrinter()
{
return withPrettyPrinter(new DefaultPrettyPrinter());
}
示例12: useDefaultPrettyPrinter
import org.codehaus.jackson.util.DefaultPrettyPrinter; //导入依赖的package包/类
public JsonGenerator useDefaultPrettyPrinter()
{
return setPrettyPrinter(new DefaultPrettyPrinter());
}