class JsonHelper {

    public String objectToJson(Object object) throws IllegalStateException
    {
        ObjectMapper mapper = new ObjectMapper();

        StringWriter stringWriter = new StringWriter();

        try
        {
            mapper.writeValue(stringWriter, object);
        }
        catch (IOException e)
        {
            throw new IllegalStateException(e);
        }

        return stringWriter.toString();
    }

}