The main issue you are facing is new line. You need to replace the newline character first, then do eval. Check the below example.
from pprint import pprint
b = '''[{
"@context": "http://database.org",
"mainEntityOfPage":"https://www.nyttimes.com/world/world_army.html",
"@type": "NewsArticle",
"text": "Now, eight months later, the $23,000 he invested in several digital tokens is worth about $4,000,
and he is clearheaded about what happened.
“I got too caught up in the fear of missing out and trying to make a quick buck,” he said last week. “The losses have pretty much left me financially ruined.”"}]'''
x= eval(b.replace('\n', ' '))
print(type(x))
pprint(x)
output:
<class 'list'>
[{'@context': 'http://database.org',
'@type': 'NewsArticle',
'mainEntityOfPage': 'https://www.nyttimes.com/world/world_army.html',
'text': 'Now, eight months later, the $23,000 he invested in several digital '
'tokens is worth about $4,000, and he is clearheaded about what '
'happened. “I got too caught up in the fear of missing out and '
'trying to make a quick buck,” he said last week. “The losses have '
'pretty much left me financially ruined.”'}]
As mentioned by FHTMitchell :
You should not use eval because of the points mentioned here
UPDATE CODE WITHOUT EVAL:
import json
from pprint import pprint
b = '''[{
"@context": "http://database.org",
"mainEntityOfPage":"https://www.nyttimes.com/world/world_army.html",
"@type": "NewsArticle",
"text": "Now, eight months later, the $23,000 he invested in several digital tokens is worth about $4,000,
and he is clearheaded about what happened.
“I got too caught up in the fear of missing out and trying to make a quick buck,” he said last week. “The losses have pretty much left me financially ruined.”"}]'''
x= json.loads(b.replace('\n', ' '))
print(type(x))
pprint(x)
Output:
<class 'list'>
[{'@context': 'http://database.org',
'@type': 'NewsArticle',
'mainEntityOfPage': 'https://www.nyttimes.com/world/world_army.html',
'text': 'Now, eight months later, the $23,000 he invested in several digital '
'tokens is worth about $4,000, and he is clearheaded about what '
'happened. “I got too caught up in the fear of missing out and '
'trying to make a quick buck,” he said last week. “The losses have '
'pretty much left me financially ruined.”'}]