I have a string from a field in a query set which looks like this:
[{'thirdParty': 'Funds Transfer'}, {'category': 'External Transfers'}, {'creditDebit': 'credit'}]
I want to be able to loop through the elements in orther to be able to get
{'thirdParty': 'Funds Transfer'}
{'category': 'External Transfers'}
{'creditDebit': 'credit'}
And also to be able to loop through the keys of that object
I am trying the following but I keep getting an error: TypeError: iteration over a 0-d array
import numpy as np
tags = "[{'thirdParty': 'Funds Transfer'}, {'category': 'External Transfers'}, {'creditDebit': 'credit'}]"
# print(type(tags))
# <class 'str'>
arr = list(np.array(tags))
# print(type(tags))
# <class 'numpy.ndarray'>
# print(tags)
# [{'thirdParty': 'Funds Transfer'}, {'category': 'External Transfers'}, {'creditDebit': 'credit'}]
for d in arr:
print(d)