make json_response and to_json take in a customer encoder as an optional param