I have a list like below in RabbitMq queue
[{'id':'10','url':'https://www.google.co.in/search?q=rabbitmq&oq=rabbitmq'},{'id':'11','url':'https://www.google.co.in/search?q=python&oq=python'}]
while consuming this message, I am getting this message like below as string but not as list
"[{'id':'10','url':'https://www.google.co.in/search?q=rabbitmq&oq=rabbitmq'},{'id':'11','url':'https://www.google.co.in/search?q=python&oq=python'}]"
I tried to convert this string to list using ast.literal_eval(my_list)
but getting SyntaxError: EOL while scanning string literal
How can I get/convert this RabbitMQ message as list?
Here is the steps to do that:
Use double quote for json array "
Use json module
import json
text = "[{'id':'10','url':'https://www.google.co.in/search?q=rabbitmq&oq=rabbitmq'},{'id':'11','url':'https://www.google.co.in/search?q=python&oq=python'}]"
text2 = text.replace("'", '"')
print json.loads(text2)