def register_json_typecasters(conn, loads_fn):
 available = set()
 for name in ['json', 'jsonb']:
  try:
   psycopg2.extras.register_json(conn, loads=loads_fn, name=name)
   available.add(name)
  except psycopg2.ProgrammingError:
   pass
 return available

def register_json_typecasters ( conn , loads_fn ) : available = set ( ) for name in [ 'json' , 'jsonb' ] : try : psycopg2 . extras . register_json ( conn , loads = loads_fn , name = name ) available . add ( name ) except psycopg2 . ProgrammingError : pass return available
set the function for converting json data for a connection .