def flatten_object(obj, result=None):
    """
    Convert a JSON object to a flatten dictionary.

    example: { "db": { "user": "bar" }} becomes {"db.user": "bar" }
    """
    if not result:
        result = {}

    def _flatten(key_obj, name=''):
        if isinstance(key_obj, dict):
            for item in key_obj:
                arg = str(name) + str(item) + '.'
                _flatten(key_obj[item], arg)
        elif isinstance(key_obj, list):
            index = 0
            for item in key_obj:
                arg = str(name) + str(index) + '.'
                _flatten(item, arg)
                index += 1
        else:
            result[name[:-1]] = key_obj

    _flatten(obj)
    return result