public static String toJson(Object object, boolean pretty) {
        try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
            toJson(object, out, pretty);
            return new String(out.toByteArray(), StandardCharsets.UTF_8);
        } catch (final IOException ex) {
            throw new JsonException(
                "Error in internal toString()-stream.", ex
            );
        }
    }
Parses the specified object to JSON and prints it to the specified
stream. The following objects are supported:
<ul>
     <li>{@code Map<String, Object>}
     <li>{@code List<Object>}
     <li>{@code String}
     <li>{@code Double}
     <li>{@code Long}
     <li>{@code null}
</ul>
<p>
This method will output a nicely formatted JSON string (with spaces and
new-lines).

@param object  the object to parse
@param pretty  if the result should be formatted in a pretty way
@return JSON String

@throws IllegalArgumentException  if the input object is of or contains
                                  unsupported types
common-parent/json/src/main/java/com/speedment/common/json/Json.java