title: How do you convert a thrift object to Json in python?
body: <p>I've tried to convert a thrift object to json in python.</p>
  
  <p>If I try to use <code>json.dumps(thriftObj)</code>, it fails with the following:</p>
  
  <p><code>TypeError: MyThriftObj(...) is not JSON serializable</code></p>
  
  <p>I tried fixing it with a default function:</p>
  
  <p><code>json.dumps(thriftObj, default=lambda x: x.__dict__)</code></p>
  
  <p>This worked in some cases but in other cases I get the error:
  <code>AttributeError: 'DictProxy' object has no attribute '__dict__'</code></p>
  
  <p>How do I convert a valid thrift object to json?</p>