json.loads() cannot convert this string list to a list while ast works properly

The string s is not a valid JSON. JSON standard does not allow single quotes for strings.

You can modify your code to replace single quotes by double quotes and It’ll work fine.

import json 

s = '["https://i.ebayimg.com/images/g/PWMAAOSw4MdfmPuu/s-l1000.jpg", "https://i.ebayimg.com/images/g/mFwAAOSw-8xfPMyu/s-l1000.jpg"]'
print(json.loads(s))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top