I am getting data in json and when i am trying to get value of one key from that json it is not working for me.
print(type(file_data))
time_file1 = json.loads(file_data)
print(time_file1)
print(type(time_file1))
print(time_file1['time_created'])
Output and error for this i am getting is:-
[{'archival_state': None, 'etag': None, 'md5': None, 'name': '.passwd.json', 'size': 1447, 'storage_tier': None, 'time_created': '2022-07-22T07:09:47.342000+00:00', 'time_modified': None}]
<class 'list'>
Traceback (most recent call last):
File "/opt/faops/spe/ocifabackup/lib/python/common/opc.py", line 69, in <module>
update_password_json_oss()
File "/opt/faops/spe/ocifabackup/lib/python/common/opc.py", line 46, in update_password_json_oss
print(time_file1['time_created'])
TypeError: list indices must be integers or slices, not str
Here when i am getting dat its str type and when i am doing json loads its changing to list type and in both cases i am not able to fetch value based on key.