def get_json_attr(obj):
  if hasattr(obj, "to_json"):
    return getattr(obj, "to_json")()
  else:
    return obj
Returns the serialized version of the object if it has to_json() defined
dataset/ETHPy150Open ucb-sts/sts/sts/util/convenience.py/get_json_attr