/** * 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; } }); }
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); }
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; }
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; }
public String toJson() { try { return new ObjectMapper().writer( new DefaultPrettyPrinter() ).writeValueAsString( this ); } catch ( Exception e ) { throw new RuntimeException( "Error serializing to JSON string", e ); } }
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() ); }
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 ); } }
public JSONArrayMeasurementsExporter(OutputStream os) throws IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os)); g = factory.createJsonGenerator(bw); g.setPrettyPrinter(new DefaultPrettyPrinter()); g.writeStartArray(); }
public JSONMeasurementsExporter(OutputStream os) throws IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os)); g = factory.createJsonGenerator(bw); g.setPrettyPrinter(new DefaultPrettyPrinter()); }
protected PrettyPrinter _defaultPrettyPrinter() { return new DefaultPrettyPrinter(); }
public ObjectWriter withDefaultPrettyPrinter() { return withPrettyPrinter(new DefaultPrettyPrinter()); }
public JsonGenerator useDefaultPrettyPrinter() { return setPrettyPrinter(new DefaultPrettyPrinter()); }