def _cast_object(x):
 x = _cast_none(x)
 if isinstance(x, six.string_types):
  try:
   return json.loads(x)
  except:
   return ast.literal_eval(x)
 else:
  return x

def _cast_object ( x ) : x = _cast_none ( x ) if isinstance ( x , six . string_types ) : try : return json . loads ( x ) except : return ast . literal_eval ( x ) else : return x
method for casting string to an object or array .