/** * Pretty-prints and formats the JSON payload. * * <p>This method calls the JsonLexer to parser the output of the builder, so this may not be an * optimal method to call, and should be used mainly for debugging purpose for a human-readable * output of the JSON content. * * @return a pretty printed JSON output */ public String toPrettyString() { return JsonOutput.prettyPrint(toString()); }
/** * Serializes the internal data structure built with the builder to a conformant JSON payload * string * * <p>Example: * * <pre><code> * def json = new JsonBuilder() * json { temperature 37 } * * assert json.toString() == '{"temperature":37}' * </code></pre> * * @return a JSON output */ public String toString() { return JsonOutput.toJson(content); }