problem is self explanatory:
import simplejson as json
a = u"[(datetime.datetime(2012, 3, 13, 14, 50, 13, 996833), 'ACTIVE', [u'my.test.service', '{}'])]"
json.loads(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 384, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 418, in raw_decode
obj, end = self.scan_once(s, idx)
simplejson.decoder.JSONDecodeError: Expecting object: line 1 column 1 (char 1)
Question is obvious: How can I convert my string to a list?
You can’t.
(datetime.datetime(2012, 3, 13, 14, 50, 13, 996833) has no meaning in JSON.
Conversely, if you try to do the opposite, you’ll notice the problem:
Edit:
Actually, reading your question again made me notice you did not specify you wanted to use JSON, just “convert the string to a list”. Not sure what your use case is, but this will work in your case: