title: JSON python to javascript
body: <p>I want to transfer some data <strong>from python to javascript</strong>. I use Django at python side and jQuery at javascript side.</p>
  
  <p>The object I serialize at python side is a dictionary. </p>
  
  <p>Besides simple objects like lists and variables, this dictionary contains instances of SomeClass. To serialize those instances I extendeded <strong>simplejson.JSONEncode</strong> like this:</p>
  
  <pre><code>class HandleSomeClass(simplejson.JSONEncoder):
      """ simplejson.JSONEncoder extension: handle SomeClass """
      def default(self, obj):
          if isinstance(obj, SomeClass):
              readyToSerialize = do_something(obj)
              readyToSerialize.magicParameter = 'SomeClass'
              return readyToSerialize
          return simplejson.JSONEncoder.default(self, obj)
  </code></pre>
  
  <p>This way, the SomeClass instances appear in JSON as dictionaries having <code>magicParameter == 'SomeClass'</code> Those instances can be nested at various deph.</p>
  
  <p>Now I would like to recreate those instances at javascript side.</p>
  
  <p>I basically would like to hava a JSON decoder, which will convert all dictionaries with <code>magicParameter == 'SomeClass'</code> to custom javascript objects using a simple object factory:</p>
  
  <pre><code>SomeClass = function( rawSomeClass ) {
  
      jQuery.extend( this, rawSomeClass ) // jQuery extend merges the newly-created object and the rawSomeClass object
  
  }
  </code></pre>
  
  <p>and then I could add methods like this to recreate the original objects:</p>
  
  <pre><code>SomeClass.prototype.get = function( arguments ) {
      // function body
  
  }
  </code></pre>
  
  <p>How to write a decoder, which will scan the JSON object and perform the convertion?</p>