/** @param knownType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Writer writer) { toJson(object, knownType, null, writer); }
/** @param knownType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, FileHandle file) { toJson(object, knownType, null, file); }
/** @param knownType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Writer writer) { toJson(object, knownType, null, writer); }
/** @param knownType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, FileHandle file) { toJson(object, knownType, null, file); }
public String toJson (Object object, Class knownType) { return toJson(object, knownType, (Class)null); }
public String toJson (Object object) { return toJson(object, object == null ? null : object.getClass(), (Class)null); }
public void toJson (Object object, Writer writer) { toJson(object, object == null ? null : object.getClass(), null, writer); }
public String toJson (Object object) { return toJson(object, object == null ? null : object.getClass(), (Class)null); }
public void toJson (Object object, Writer writer) { toJson(object, object == null ? null : object.getClass(), null, writer); }
public void toJson (Object object, FileHandle file) { toJson(object, object == null ? null : object.getClass(), null, file); }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public String toJson (Object object, Class knownType, Class elementType) { StringWriter buffer = new StringWriter(); toJson(object, knownType, elementType, buffer); return buffer.toString(); }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public String toJson (Object object, Class knownType, Class elementType) { StringWriter buffer = new StringWriter(); toJson(object, knownType, elementType, buffer); return buffer.toString(); }
public String prettyPrint (Object object, int singleLineColumns) { return prettyPrint(toJson(object), singleLineColumns); }
public String prettyPrint (Object object, PrettyPrintSettings settings) { return prettyPrint(toJson(object), settings); }
public String prettyPrint (Object object, int singleLineColumns) { return prettyPrint(toJson(object), singleLineColumns); }
private String roundTrip (Object object) { String text = json.toJson(object); System.out.println(text); test(text, object); text = json.prettyPrint(object, 130); test(text, object); return text; }
/** Sets the correct {@code ContentType} and encodes the given content object via {@link #json}, then sets it as the content. */ public HttpRequestBuilder jsonContent (Object content) { validate(); httpRequest.setHeader(HttpRequestHeader.ContentType, "application/json"); String jsonContent = json.toJson(content); httpRequest.setContent(jsonContent); return this; }
/** Sets the correct {@code ContentType} and encodes the given content object via {@link #json}, then sets it as the content. */ public HttpRequestBuilder jsonContent (Object content) { validate(); httpRequest.setHeader(HttpRequestHeader.ContentType, "application/json"); String jsonContent = json.toJson(content); httpRequest.setContent(jsonContent); return this; }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Class elementType, FileHandle file) { Writer writer = null; try { writer = file.writer(false, "UTF-8"); toJson(object, knownType, elementType, writer); } catch (Exception ex) { throw new SerializationException("Error writing file: " + file, ex); } finally { StreamUtils.closeQuietly(writer); } }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Class elementType, FileHandle file) { Writer writer = null; try { writer = file.writer(false, "UTF-8"); toJson(object, knownType, elementType, writer); } catch (Exception ex) { throw new SerializationException("Error writing file: " + file, ex); } finally { StreamUtils.closeQuietly(writer); } }