<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_ret(return_set, as_json=False):
 """ decouple, allow for modifications to return type returns a list of ip addresses in object or json form """

    ret_list = list()
    for item in return_set:
        d = {"ip": item}
        ret_list.append(d)

    if as_json:
        return json.dumps(ret_list)

    return ret_list