TypeError: 'tasks:meta:newtask' is not JSON serializable
<p>I am trying to dump this json - </p>

<pre><code>{'total_run_count': 9, 'task': 'tasks.add', 'enabled': True, 'schedule': {'period': 'seconds', 'every': 3}, 'kwargs': {'max_targets': 100}, 'running': False, 'options': {}, 'delete_key': 'deleted:tasks:meta:newtask', 'name': b'tasks:meta:newtask', 'last_run_at': datetime.datetime(2016, 10, 3, 19, 9, 50, 162098), 'args': ['3', '2'], 'key': 'tasks:meta:newtask'}
</code></pre>

<p>and it fails for the key 'name'. I have decoded it in utf-8 but still not luck. I am getting the following error.</p>

<p>TypeError: 'tasks:meta:newtask' is not JSON serializable</p>

<p>what is not serializable about the above string ? I am clueless.</p>

<p>Notice how that item is displayed in the dictionary:</p>

<pre><code>'name': b'tasks:meta:newtask'
</code></pre>

<p>That leading <code>b</code> indicates that 'tasks:meta:newtask' is a <em>byte string</em>, not a regular character string.  JSON is telling you that it doesn't know how to handle a byte string object.</p>

<p>Does it really need to be a byte string?  If not, you should convert it to a regular string before calling json dump.</p>

python