/** * This performs a shallow serialization of the target instance. It uses a StringBuilder to write output to. * * @param target - the instance to serialize to JSON * @return returns JSON as a String */ public String serialize(Object target) { return serialize(target, SerializationType.SHALLOW, new StringBuilderOutputHandler(new StringBuilder())); }
/** * This performs a shallow serialization of the target instance and * passes the generated JSON into the provided StringBuilder. * * @param target - the instance to serialize to JSON * @param out - StringBuilder to write output to * @return returns JSON as a String */ public String serialize(Object target, StringBuilder out) { return serialize(target, SerializationType.SHALLOW, new StringBuilderOutputHandler(out)); }
/** * This performs a deep serialization of the target instance and * passes the generated JSON into the provided StringBuilder. * * @param target - the instance to serialize to JSON * @param out - StringBuilder * @return returns JSON as a String */ public String deepSerialize(Object target, StringBuilder out) { return serialize(target, SerializationType.DEEP, new StringBuilderOutputHandler(out)); }
/** * This performs a deep serialization of the target instance. It will include * all collections, maps, and arrays by default so includes are ignored except * if you want to include something being excluded by an annotation. Excludes * are honored. However, cycles in the target's graph are NOT followed. This * means some members won't be included in the JSON if they would create a cycle. * Rather than throwing an exception the cycle creating members are simply not * followed. This uses a StringBuilder to output JSON to. * * @param target the instance to serialize to JSON. * @return returns JSON as a String */ public String deepSerialize(Object target) { return serialize(target, SerializationType.DEEP, new StringBuilderOutputHandler(new StringBuilder())); }