@Override
    public boolean serialize(JsonSerializer serializer, JsonFragmentBuilder builder, Object value) {
        boolean result;
        
        Method toJson=findMethod(value.getClass(), boolean.class, Arrays.asList("toJson"), JsonFragmentBuilder.class);
        if(toJson != null) {
            try {
                result = (Boolean) toJson.invoke(value, builder);
            }
            catch (IllegalArgumentException e) {
                JsonSerializationException e2=serializer.getExceptionPolicy().format(e);
                if(e2 != null)
                    throw e2;
                result = false;
            }
            catch (IllegalAccessException e) {
                JsonSerializationException e2=serializer.getExceptionPolicy().format(e);
                if(e2 != null)
                    throw e2;
                result = false;
            }
            catch (InvocationTargetException e) {
                JsonSerializationException e2=serializer.getExceptionPolicy().format(e);
                if(e2 != null)
                    throw e2;
                result = false;
            }
        }
        else
            result = false;
        
        return result;
    }