code: public String toJSONString(final boolean compact) {
          final StringBuilder builder = new StringBuilder();
          formatAsJSON(builder, 0, !compact);
          return builder.toString();
      }
docs: Converts this value to a JSON string representation.
  @param compact Flag indicating whether or not to include new lines
  in the generated string representation.
  @return The JSON formatted string.