converting python api objects to json