title: How to use __get__ to make object JSON serializable?
body: <p>I have a decorator that returns a string on <code>__get__</code>. How can I make it compatible with <code>json.dumps</code>?</p>
  
  <pre><code>import json
  
  class Decorator(object):
      def __init__(self, value=''):
          self.value = value
      def __set__(self, instance, value):
          self.value = value
      def __get__(self, instance, owner):
          return self.value
  
  class Foo(object):
      decorator = Decorator()
  
  foo = Foo('Hello World')
  json.dumps(foo)
  </code></pre>
  
  <p>This minimal example raises an exception in <code>json.dumps</code> stating that <code>Decorator</code> is not serializable. Since it is not a real string but just provide a string like interface that's not surprising. How can I make it JSON serializable using the value returned by <code>__get__</code>?</p>