public static String toPrettyJson(Object object) { CharBuf buf = CharBuf.createCharBuf(); return buf.prettyPrintObject(object, false, 0).toString(); }
public static CharBuf create( int capacity ) { return new CharBuf( capacity ); }
public static String toPrettyJson(List list) { CharBuf buf = CharBuf.createCharBuf(); return buf.prettyPrintCollection(list, false, 0).toString(); } }
public static String asPrettyJsonString(Mapper mapper, Object bean) { CharBuf buf = CharBuf.createCharBuf(); return buf.prettyPrintBean(mapper, bean).toString(); }
public static String toString( Exception ex ) { CharBuf buffer = CharBuf.create( 255 ); buffer.addLine( ex.getLocalizedMessage() ); final StackTraceElement[] stackTrace = ex.getStackTrace(); for ( StackTraceElement element : stackTrace ) { buffer.add( element.getClassName() ); sputs( " ", buffer, "class", element.getClassName(), "method", element.getMethodName(), "line", element.getLineNumber() ); } return buffer.toString(); }
public String toStringAndRecycle() { String str = this.toString(); location = 0; return str; }
public static String asPrettyJsonString(Map<String, Object> map) { CharBuf buf = CharBuf.createCharBuf(); return buf.prettyPrintMap(map).toString(); }
@Override public String encodeAsString(Response<Object> response) { CharBuf buf = CharBuf.createCharBuf(); encodeAsString(buf, response); return buf.toString(); }
@Override public final void serializeDate( JsonSerializerInternal jsonSerializer, Date date, CharBuf builder ) { String string = dateCache.get ( date ); if ( string == null) { CharBuf buf = CharBuf.create ( Dates.JSON_TIME_LENGTH ); Dates.jsonDateChars ( calendar, date, buf ); string = buf.toString(); dateCache.put ( date, string ); } builder.addChars ( FastStringUtils.toCharArray( string ) ); } }
public static String decodeForSure( char[] chars, int start, int to ) { CharBuf builder = CharBuf.create( to - start ); builder.decodeJsonString(chars, start, to); return builder.toString(); }
@Test public void testMe() { CharBuf buf = new CharBuf(); buf.add( chars( "0123456789\n" ) ); buf.add( "0123456789\n" ); buf.add( "0123456789\n" ); buf.add( "0123456789\n" ); buf.add( "0123456789\n" ); buf.add( "0123456END\n" ); String out = buf.toString(); assertEquals( 66, out.length() ); assertTrue( out.endsWith( "END\n" ) ); }
public CharBuf prettyPrintCollection(Collection values, boolean type, int indent) { add('['); for (Object value : values) { prettyPrintObject(value, type, indent); add(','); } if (values.size()>0) { removeLastChar(); } add(']'); return this; }
public JsonSimpleSerializerImpl() { this.view = null; this.encodeStrings = true; serializeAsSupport = true; builder = CharBuf.create( 4000 ); }
private CharBuf prettyPrintBuf() { CharBuf buf = prettyPrintBuf.get(); if (buf == null) { buf = CharBuf.createCharBuf(); prettyPrintBuf.set(buf); } return buf; }