private void serializeInternal(Object object) throws IOException {
        if (object==null) {
            writer.write("null");
        } else if (object instanceof String) {
            quote((String)object);
        } else if (object instanceof Number) {
            numberToString((Number) object);
        } else if (object instanceof Map) {
            serializeMap((Map) object);
        } else if (object instanceof List) {
            serializeArray((List) object);
        } else if (object.getClass().isArray()) {
            serializeArray((Object[]) object);// && object.getClass().getComponentType().equals(Double.TYPE) double[]) object);
        } else if (object instanceof Boolean) {
            writer.write(((Boolean)object).toString()); 
        } else if (object instanceof Date) {
            quote(dateFormatter.format((Date) object)); 
        } else {
            throw serializeError("Unknown object type " + object.getClass().toString());
        }
    }