Python json.dumps equivalent that returns a dictionary with built-in data types
<p>I'm working with a library that contains a number of classes that are subclasses of the <code>dict</code> type. I can get a JSON string of the object by calling the following:</p>

<pre><code>import json

json.dumps(customer, sort_keys=True, indent=2)
</code></pre>

<p>However, I'm working with a NoSQL database and I need to convert this class to a dictionary in order to properly save it. Unfortunately, calling <code>dict(customer)</code> does not provide me with a valid structure since a number of it's objects are unhashable types. However, I discovered I can perform a <code>json.dumps</code> and <code>json.loads</code> to convert the object to a dictionary that I can now save:</p>

<pre><code>import json

json_str = json.dumps(customer, sort_keys=True, indent=2)
customer_obj = json.loads(json_str)

# I can now save the customer_obj
</code></pre>

<p>Ultimately, I would like to know if there is more direct way to create my JSON-like dictionary without subsequently calling <code>json.dumps</code> and <code>json.loads</code>.</p>