I'm just guessing here, since you didn't give us the traceback or enough information to reproduce your problem, but I suspect it's this:
activity = ast.literal_eval(json.dumps(value))
You're taking value
, which is presumably some kind of Python object, calling json.dumps
to turn it into a JSON string representing that object, then calling ast.literal_eval
to turn it back into the original object. That can't possibly be useful.
Meanwhile, the error seems to be saying that you have a string when it's expecting some other kind of object (most likely a list or other mutable sequence). If value
is already a JSON string, you want to use json.loads
to get a Python object out of it. If it's a Python literal string itself, you want to use ast.literal_eval
on the string, not on a JSON string representing the original string. If it's some other thing… well, we'd need to know what other thing to know how to decode it. The only thing I can be sure of is that there's no conceivable thing it could be for which your code would be useful.