in src/gcf/main.py [0:0]
def read_json_str(bucket_name: str, file_name: str) -> Optional[str]:
"""
Read JSON file from GCS bucket.
Args:
bucket_name: bucket name containingh image
file_name: path+file name of JSON file
Returns:
File contents as JSON string.
"""
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(file_name)
try:
json_str = blob.download_as_string()
if json_str:
json_obj = json.loads(json_str)
return json_obj
except Exception:
pass
return None